perf expr: Make expr__parse() return -1 on error
authorJiri Olsa <jolsa@kernel.org>
Fri, 28 Feb 2020 09:36:16 +0000 (10:36 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 10 Mar 2020 00:43:25 +0000 (21:43 -0300)
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@kernel.org>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20200228093616.67125-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/expr.c
tools/perf/util/expr.c

index 755d73c86c68643db243d05d8b3bd21097a51e11..28313e59d6f6ab959184efc45de3b62b41a2a75a 100644 (file)
@@ -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);
index 45b25530db5b43435d55669eed4e5768e5d21a19..fd192ddf93c16c6200fe6ae98275950f8975fdb9 100644 (file)
@@ -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