diff options
author | Mamatha Inamdar <mamatha4@linux.vnet.ibm.com> | 2019-08-22 03:20:49 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-09-20 14:58:11 -0400 |
commit | 6ef81c55a2b6584cb642917f5fdf3632ef44b670 (patch) | |
tree | 524c57e82fa0f5b59b5bec95b65c3066015fbe02 /tools/perf/builtin-annotate.c | |
parent | 9e6124d9d635957b56717f85219a88701617253f (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-annotate.c')
-rw-r--r-- | tools/perf/builtin-annotate.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 553c651fa0a2..8db8fc9bddef 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <dlfcn.h> | 40 | #include <dlfcn.h> |
41 | #include <errno.h> | 41 | #include <errno.h> |
42 | #include <linux/bitmap.h> | 42 | #include <linux/bitmap.h> |
43 | #include <linux/err.h> | ||
43 | 44 | ||
44 | struct perf_annotate { | 45 | struct perf_annotate { |
45 | struct perf_tool tool; | 46 | struct perf_tool tool; |
@@ -584,8 +585,8 @@ int cmd_annotate(int argc, const char **argv) | |||
584 | data.path = input_name; | 585 | data.path = input_name; |
585 | 586 | ||
586 | annotate.session = perf_session__new(&data, false, &annotate.tool); | 587 | annotate.session = perf_session__new(&data, false, &annotate.tool); |
587 | if (annotate.session == NULL) | 588 | if (IS_ERR(annotate.session)) |
588 | return -1; | 589 | return PTR_ERR(annotate.session); |
589 | 590 | ||
590 | annotate.has_br_stack = perf_header__has_feat(&annotate.session->header, | 591 | annotate.has_br_stack = perf_header__has_feat(&annotate.session->header, |
591 | HEADER_BRANCH_STACK); | 592 | HEADER_BRANCH_STACK); |