Skip to content
Commit 6a8faf10 authored by Yafang Shao's avatar Yafang Shao Committed by Daniel Borkmann
Browse files

bpftool: Fix build warnings with -Wtype-limits



Quentin reported build warnings when building bpftool :

    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 ...]

He also pointed out the reason and the solution:

  We're always passing unsigned, so it should be safe to drop the check on
  (id) >= 0.

Fixes: 62b57e3d ("bpftool: Add perf event names")
Reported-by: default avatarQuentin Monnet <quentin@isovalent.com>
Suggested-by: default avatarQuentin Monnet <quentin@isovalent.com>
Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
Signed-off-by: Daniel Borkmann <danie...
parent 32337c0a
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