Commit 41636448 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events: Avoid enum casts

Add term_type to union of values returned by the lexer to avoid casts
to and from an integer.
Reviewed-by: default avatarJames Clark <james.clark@arm.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230901233949.2930562-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 8f91662e
......@@ -120,7 +120,7 @@ static int term(yyscan_t scanner, enum parse_events__term_type type)
{
YYSTYPE *yylval = parse_events_get_lval(scanner);
yylval->num = type;
yylval->term_type = type;
return PE_TERM;
}
......
......@@ -70,7 +70,7 @@ static void free_list_evsel(struct list_head* list_evsel)
%type <num> PE_VALUE_SYM_HW
%type <num> PE_VALUE_SYM_SW
%type <num> PE_VALUE_SYM_TOOL
%type <num> PE_TERM
%type <term_type> PE_TERM
%type <num> value_sym
%type <str> PE_RAW
%type <str> PE_NAME
......@@ -111,6 +111,7 @@ static void free_list_evsel(struct list_head* list_evsel)
{
char *str;
u64 num;
enum parse_events__term_type term_type;
struct list_head *list_evsel;
struct list_head *list_terms;
struct parse_events_term *term;
......@@ -778,8 +779,7 @@ PE_TERM_HW
PE_TERM '=' name_or_legacy
{
struct parse_events_term *term;
int err = parse_events_term__str(&term, (enum parse_events__term_type)$1,
/*config=*/NULL, $3, &@1, &@3);
int err = parse_events_term__str(&term, $1, /*config=*/NULL, $3, &@1, &@3);
if (err) {
free($3);
......@@ -791,8 +791,7 @@ PE_TERM '=' name_or_legacy
PE_TERM '=' PE_TERM_HW
{
struct parse_events_term *term;
int err = parse_events_term__str(&term, (enum parse_events__term_type)$1,
/*config=*/NULL, $3.str, &@1, &@3);
int err = parse_events_term__str(&term, $1, /*config=*/NULL, $3.str, &@1, &@3);
if (err) {
free($3.str);
......@@ -804,10 +803,7 @@ PE_TERM '=' PE_TERM_HW
PE_TERM '=' PE_TERM
{
struct parse_events_term *term;
int err = parse_events_term__term(&term,
(enum parse_events__term_type)$1,
(enum parse_events__term_type)$3,
&@1, &@3);
int err = parse_events_term__term(&term, $1, $3, &@1, &@3);
if (err)
PE_ABORT(err);
......@@ -818,8 +814,9 @@ PE_TERM '=' PE_TERM
PE_TERM '=' PE_VALUE
{
struct parse_events_term *term;
int err = parse_events_term__num(&term, (enum parse_events__term_type)$1,
/*config=*/NULL, $3, /*novalue=*/false, &@1, &@3);
int err = parse_events_term__num(&term, $1,
/*config=*/NULL, $3, /*novalue=*/false,
&@1, &@3);
if (err)
PE_ABORT(err);
......@@ -830,9 +827,9 @@ PE_TERM '=' PE_VALUE
PE_TERM
{
struct parse_events_term *term;
int err = parse_events_term__num(&term, (enum parse_events__term_type)$1,
/*config=*/NULL, /*num=*/1, /*novalue=*/true,
&@1, /*loc_val=*/NULL);
int err = parse_events_term__num(&term, $1,
/*config=*/NULL, /*num=*/1, /*novalue=*/true,
&@1, /*loc_val=*/NULL);
if (err)
PE_ABORT(err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment