summaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-sched.c
diff options
context:
space:
mode:
authorMamatha Inamdar <mamatha4@linux.vnet.ibm.com>2019-08-22 03:20:49 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-09-20 14:58:11 -0400
commit6ef81c55a2b6584cb642917f5fdf3632ef44b670 (patch)
tree524c57e82fa0f5b59b5bec95b65c3066015fbe02 /tools/perf/builtin-sched.c
parent9e6124d9d635957b56717f85219a88701617253f (diff)
perf session: Return error code for perf_session__new() function on failure
This patch is to return error code of perf_new_session function on failure instead of NULL. Test Results: Before Fix: $ perf c2c report -input failed to open nput: No such file or directory $ echo $? 0 $ After Fix: $ perf c2c report -input failed to open nput: No such file or directory $ echo $? 254 $ Committer notes: Fix 'perf tests topology' case, where we use that TEST_ASSERT_VAL(..., session), i.e. we need to pass zero in case of failure, which was the case before when NULL was returned by perf_session__new() for failure, but now we need to negate the result of IS_ERR(session) to respect that TEST_ASSERT_VAL) expectation of zero meaning failure. Reported-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com> Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com> Acked-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Reviewed-by: Mukesh Ojha <mojha@codeaurora.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Shawn Landden <shawn@git.icu> Cc: Song Liu <songliubraving@fb.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com> Link: http://lore.kernel.org/lkml/20190822071223.17892.45782.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r--tools/perf/builtin-sched.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index f0b828c201cc..079e67a36904 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -40,6 +40,7 @@
40#include <api/fs/fs.h> 40#include <api/fs/fs.h>
41#include <perf/cpumap.h> 41#include <perf/cpumap.h>
42#include <linux/time64.h> 42#include <linux/time64.h>
43#include <linux/err.h>
43 44
44#include <linux/ctype.h> 45#include <linux/ctype.h>
45 46
@@ -1797,9 +1798,9 @@ static int perf_sched__read_events(struct perf_sched *sched)
1797 int rc = -1; 1798 int rc = -1;
1798 1799
1799 session = perf_session__new(&data, false, &sched->tool); 1800 session = perf_session__new(&data, false, &sched->tool);
1800 if (session == NULL) { 1801 if (IS_ERR(session)) {
1801 pr_debug("No Memory for session\n"); 1802 pr_debug("Error creating perf session");
1802 return -1; 1803 return PTR_ERR(session);
1803 } 1804 }
1804 1805
1805 symbol__init(&session->header.env); 1806 symbol__init(&session->header.env);
@@ -2989,8 +2990,8 @@ static int perf_sched__timehist(struct perf_sched *sched)
2989 symbol_conf.use_callchain = sched->show_callchain; 2990 symbol_conf.use_callchain = sched->show_callchain;
2990 2991
2991 session = perf_session__new(&data, false, &sched->tool); 2992 session = perf_session__new(&data, false, &sched->tool);
2992 if (session == NULL) 2993 if (IS_ERR(session))
2993 return -ENOMEM; 2994 return PTR_ERR(session);
2994 2995
2995 evlist = session->evlist; 2996 evlist = session->evlist;
2996 2997