Skip to content

Commit acd50fc

Browse files
captain5050gregkh
authored andcommitted
perf parse-events: Remove ABORT_ON
[ Upstream commit 4c11adf ] Prefer informative messages rather than none with ABORT_ON. Document one failure mode and add an error message for another. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Stable-dep-of: ede72dc ("perf parse-events: Fix tracepoint name memory leak") Signed-off-by: Sasha Levin <[email protected]>
1 parent ee4558a commit acd50fc

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tools/perf/util/parse-events.y

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222

2323
void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg);
2424

25-
#define ABORT_ON(val) \
26-
do { \
27-
if (val) \
28-
YYABORT; \
29-
} while (0)
30-
3125
#define PE_ABORT(val) \
3226
do { \
3327
if (val == -ENOMEM) \
@@ -618,7 +612,9 @@ PE_RAW opt_event_config
618612
YYNOMEM;
619613
errno = 0;
620614
num = strtoull($1 + 1, NULL, 16);
621-
ABORT_ON(errno);
615+
/* Given the lexer will only give [a-fA-F0-9]+ a failure here should be impossible. */
616+
if (errno)
617+
YYABORT;
622618
free($1);
623619
err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, num, $2,
624620
/*wildcard=*/false);
@@ -978,7 +974,17 @@ PE_VALUE PE_ARRAY_RANGE PE_VALUE
978974
{
979975
struct parse_events_array array;
980976

981-
ABORT_ON($3 < $1);
977+
if ($3 < $1) {
978+
struct parse_events_state *parse_state = _parse_state;
979+
struct parse_events_error *error = parse_state->error;
980+
char *err_str;
981+
982+
if (asprintf(&err_str, "Expected '%ld' to be less-than '%ld'", $3, $1) < 0)
983+
err_str = NULL;
984+
985+
parse_events_error__handle(error, @1.first_column, err_str, NULL);
986+
YYABORT;
987+
}
982988
array.nr_ranges = 1;
983989
array.ranges = malloc(sizeof(array.ranges[0]));
984990
if (!array.ranges)

0 commit comments

Comments
 (0)