]> www.infradead.org Git - users/jedix/linux-maple.git/commit
perf tools: Fix possible compiler warnings in hashmap
authorNamhyung Kim <namhyung@kernel.org>
Wed, 9 Oct 2024 20:20:08 +0000 (13:20 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 14 Oct 2024 19:04:31 +0000 (12:04 -0700)
commit04042674b21a8dfa143abacf7b1ef5b25a58d86e
treead3ea1c56a529c9c0faf3f6fb5e14428b213f620
parent77b679453d3364688ff3e5153c0be5b2b52672b7
perf tools: Fix possible compiler warnings in hashmap

The hashmap__for_each_entry[_safe] is accessing 'map' as if it's a
pointer.  But it does without parentheses so passing a static hash map
with an ampersand (like &slab_hash below) caused compiler warnings due
to unmatched types.

  In file included from util/bpf_lock_contention.c:5:
  util/bpf_lock_contention.c: In function ‘exit_slab_cache_iter’:
  linux/tools/perf/util/hashmap.h:169:32: error: invalid type argument of ‘->’ (have ‘struct hashmap’)
    169 |         for (bkt = 0; bkt < map->cap; bkt++)                                \
        |                                ^~
  util/bpf_lock_contention.c:105:9: note: in expansion of macro ‘hashmap__for_each_entry’
    105 |         hashmap__for_each_entry(&slab_hash, cur, bkt)
        |         ^~~~~~~~~~~~~~~~~~~~~~~
  /home/namhyung/project/linux/tools/perf/util/hashmap.h:170:31: error: invalid type argument of ‘->’ (have ‘struct hashmap’)
    170 |                 for (cur = map->buckets[bkt]; cur; cur = cur->next)
        |                               ^~
  util/bpf_lock_contention.c:105:9: note: in expansion of macro ‘hashmap__for_each_entry’
    105 |         hashmap__for_each_entry(&slab_hash, cur, bkt)
        |         ^~~~~~~~~~~~~~~~~~~~~~~

Cc: bpf@vger.kernel.org
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20241009202009.884884-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/hashmap.h