diff options
author | 2023-08-31 00:14:20 -0700 | |
---|---|---|
committer | 2023-08-31 16:24:55 -0300 | |
commit | 58d3a4cea4a45414a21a712078d95b39dcdda10d (patch) | |
tree | d629b62bc661e76ca12770be861f099b9391aa63 /tools/perf/util/parse-events.y | |
parent | perf list: Don't print Unit for "default_core" (diff) | |
download | linux-58d3a4cea4a45414a21a712078d95b39dcdda10d.tar.gz linux-58d3a4cea4a45414a21a712078d95b39dcdda10d.tar.bz2 linux-58d3a4cea4a45414a21a712078d95b39dcdda10d.zip |
perf parse-events: Name the two term enums
Name the enums used by 'struct parse_events_term' to
parse_events__term_val_type and parse_events__term_type.
This allows greater compile time error checking.
Fix -Wswitch related issues by explicitly listing all enum values prior
to default.
Add config_term_name to safely look up a parse_events__term_type name,
bounds checking the array access first.
Add documentation to 'struct parse_events_terms' and reorder to save
space.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
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/20230831071421.2201358-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/parse-events.y')
-rw-r--r-- | tools/perf/util/parse-events.y | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 4a370c36a0d5..534daed91c50 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -777,7 +777,8 @@ PE_TERM_HW PE_TERM '=' name_or_legacy { struct parse_events_term *term; - int err = parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3); + int err = parse_events_term__str(&term, (enum parse_events__term_type)$1, + /*config=*/NULL, $3, &@1, &@3); if (err) { free($3); @@ -789,7 +790,8 @@ PE_TERM '=' name_or_legacy PE_TERM '=' PE_TERM_HW { struct parse_events_term *term; - int err = parse_events_term__str(&term, (int)$1, NULL, $3.str, &@1, &@3); + int err = parse_events_term__str(&term, (enum parse_events__term_type)$1, + /*config=*/NULL, $3.str, &@1, &@3); if (err) { free($3.str); @@ -801,7 +803,10 @@ PE_TERM '=' PE_TERM_HW PE_TERM '=' PE_TERM { struct parse_events_term *term; - int err = parse_events_term__term(&term, (int)$1, (int)$3, &@1, &@3); + int err = parse_events_term__term(&term, + (enum parse_events__term_type)$1, + (enum parse_events__term_type)$3, + &@1, &@3); if (err) PE_ABORT(err); @@ -812,7 +817,8 @@ PE_TERM '=' PE_TERM PE_TERM '=' PE_VALUE { struct parse_events_term *term; - int err = parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3); + int err = parse_events_term__num(&term, (enum parse_events__term_type)$1, + /*config=*/NULL, $3, /*novalue=*/false, &@1, &@3); if (err) PE_ABORT(err); @@ -823,7 +829,9 @@ PE_TERM '=' PE_VALUE PE_TERM { struct parse_events_term *term; - int err = parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL); + int err = parse_events_term__num(&term, (enum parse_events__term_type)$1, + /*config=*/NULL, /*num=*/1, /*novalue=*/true, + &@1, /*loc_val=*/NULL); if (err) PE_ABORT(err); |