Skip to content

Commit

Permalink
perf parse-events: Remove ABORT_ON
Browse files Browse the repository at this point in the history
[ 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]>
  • Loading branch information
captain5050 authored and gregkh committed Nov 20, 2023
1 parent ee4558a commit acd50fc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tools/perf/util/parse-events.y
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@

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

#define ABORT_ON(val) \
do { \
if (val) \
YYABORT; \
} while (0)

#define PE_ABORT(val) \
do { \
if (val == -ENOMEM) \
Expand Down Expand Up @@ -618,7 +612,9 @@ PE_RAW opt_event_config
YYNOMEM;
errno = 0;
num = strtoull($1 + 1, NULL, 16);
ABORT_ON(errno);
/* Given the lexer will only give [a-fA-F0-9]+ a failure here should be impossible. */
if (errno)
YYABORT;
free($1);
err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, num, $2,
/*wildcard=*/false);
Expand Down Expand Up @@ -978,7 +974,17 @@ PE_VALUE PE_ARRAY_RANGE PE_VALUE
{
struct parse_events_array array;

ABORT_ON($3 < $1);
if ($3 < $1) {
struct parse_events_state *parse_state = _parse_state;
struct parse_events_error *error = parse_state->error;
char *err_str;

if (asprintf(&err_str, "Expected '%ld' to be less-than '%ld'", $3, $1) < 0)
err_str = NULL;

parse_events_error__handle(error, @1.first_column, err_str, NULL);
YYABORT;
}
array.nr_ranges = 1;
array.ranges = malloc(sizeof(array.ranges[0]));
if (!array.ranges)
Expand Down

0 comments on commit acd50fc

Please sign in to comment.