71 lines
2.5 KiB
Diff
71 lines
2.5 KiB
Diff
From 118a571d1fc8498e12ed2f2eeac50774616a16b1 Mon Sep 17 00:00:00 2001
|
|
From: Jiri Olsa <jolsa@kernel.org>
|
|
Date: Fri, 28 Feb 2020 10:36:16 +0100
|
|
Subject: [PATCH 056/201] perf expr: Make expr__parse() return -1 on error
|
|
|
|
mainline inclusion
|
|
from mainline-v5.7-rc1
|
|
commit d942815a76463fa53b81d3d1c064f76bb3f80ead
|
|
category: feature
|
|
bugzilla: https://gitee.com/openeuler/kernel/issues/I8C0CX
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d942815a76463fa53b81d3d1c064f76bb3f80ead
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
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>
|
|
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
|
|
---
|
|
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 153977e91e78..9fd4ba83fbe0 100644
|
|
--- a/tools/perf/tests/expr.c
|
|
+++ b/tools/perf/tests/expr.c
|
|
@@ -43,11 +43,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.27.0
|
|
|