Skip to content

Commit

Permalink
selftests/bpf: Fix warning comparing pointer to 0
Browse files Browse the repository at this point in the history
Avoid pointer type value compared with 0 to make code clear. Reported by
coccicheck:

  tools/testing/selftests/bpf/progs/map_ptr_kern.c:370:21-22:
  WARNING comparing pointer to 0
  tools/testing/selftests/bpf/progs/map_ptr_kern.c:397:21-22:
  WARNING comparing pointer to 0

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/1648605588-19269-1-git-send-email-baihaowen@meizu.com
  • Loading branch information
Haowen Bai authored and Daniel Borkmann committed Mar 30, 2022
1 parent d31e038 commit 2609f63
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/progs/map_ptr_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static inline int check_array_of_maps(void)

VERIFY(check_default(&array_of_maps->map, map));
inner_map = bpf_map_lookup_elem(array_of_maps, &key);
VERIFY(inner_map != 0);
VERIFY(inner_map != NULL);
VERIFY(inner_map->map.max_entries == INNER_MAX_ENTRIES);

return 1;
Expand All @@ -394,7 +394,7 @@ static inline int check_hash_of_maps(void)

VERIFY(check_default(&hash_of_maps->map, map));
inner_map = bpf_map_lookup_elem(hash_of_maps, &key);
VERIFY(inner_map != 0);
VERIFY(inner_map != NULL);
VERIFY(inner_map->map.max_entries == INNER_MAX_ENTRIES);

return 1;
Expand Down

0 comments on commit 2609f63

Please sign in to comment.