On 09/07/2023 03:56, Yafang Shao wrote: > Add new functions and macros to get perf event names. These names except > the perf_type_name are all copied from > tool/perf/util/{parse-events,evsel}.c, so that in the future we will > have a good chance to use the same code. > > Suggested-by: Jiri Olsa <olsajiri@xxxxxxxxx> > Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> > Reviewed-by: Quentin Monnet <quentin@xxxxxxxxxxxxx> > Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx> > --- > tools/bpf/bpftool/link.c | 67 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 67 insertions(+) > > diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c > index a4f5a436777f..8e4d9176a6e8 100644 > --- a/tools/bpf/bpftool/link.c > +++ b/tools/bpf/bpftool/link.c [...] > +#define perf_event_name(array, id) ({ \ > + const char *event_str = NULL; \ > + \ > + if ((id) >= 0 && (id) < ARRAY_SIZE(array)) \ Hi Yafang, I'm observing build warnings when building bpftool after you series: link.c: In function ‘perf_config_hw_cache_str’: link.c:86:18: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits] 86 | if ((id) >= 0 && (id) < ARRAY_SIZE(array)) \ | ^~ link.c:320:20: note: in expansion of macro ‘perf_event_name’ 320 | hw_cache = perf_event_name(evsel__hw_cache, config & 0xff); | ^~~~~~~~~~~~~~~ [... more of the same for the other calls to perf_event_name ...] (using GCC 11.4.0) Could you please send a follow-up to suppress them? We're always passing unsigned, so it should be safe to drop the check on (id) >= 0. Thanks, Quentin