[PATCH 15/19] perf expr: Make expr__parse() return -1 on error
From: Arnaldo Carvalho de Melo
Date: Tue Mar 10 2020 - 07:17:04 EST
From: Jiri Olsa <jolsa@xxxxxxxxxx>
To match the error value of the expr__find_other function, so all
exported expr functions return the same values:
0 on success, -1 on error.
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Reviewed-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Cc: John Garry <john.garry@xxxxxxxxxx>
Cc: Kajol Jain <kjain@xxxxxxxxxxxxx>
Cc: Michael Petlan <mpetlan@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxx>
Link: http://lore.kernel.org/lkml/20200228093616.67125-6-jolsa@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/tests/expr.c | 4 ++--
tools/perf/util/expr.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
index 755d73c86c68..28313e59d6f6 100644
--- a/tools/perf/tests/expr.c
+++ b/tools/perf/tests/expr.c
@@ -45,11 +45,11 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
p = "FOO/0";
ret = expr__parse(&val, &ctx, p);
- TEST_ASSERT_VAL("division by zero", ret == 1);
+ TEST_ASSERT_VAL("division by zero", ret == -1);
p = "BAR/";
ret = expr__parse(&val, &ctx, p);
- TEST_ASSERT_VAL("missing operand", ret == 1);
+ TEST_ASSERT_VAL("missing operand", ret == -1);
TEST_ASSERT_VAL("find other",
expr__find_other("FOO + BAR + BAZ + BOZO", "FOO", &other, &num_other) == 0);
diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index 45b25530db5b..fd192ddf93c1 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -54,7 +54,7 @@ __expr__parse(double *val, struct parse_ctx *ctx, const char *expr,
int expr__parse(double *final_val, struct parse_ctx *ctx, const char *expr)
{
- return __expr__parse(final_val, ctx, expr, EXPR_PARSE);
+ return __expr__parse(final_val, ctx, expr, EXPR_PARSE) ? -1 : 0;
}
static bool
--
2.21.1