aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorGravatar Ben Dooks <ben.dooks@sifive.com> 2022-07-14 11:03:22 +0100
committerGravatar Andrii Nakryiko <andrii@kernel.org> 2022-07-15 09:55:20 -0700
commita2a5580fcbf808e7c2310e4959b62f9d2157fdb6 (patch)
tree05cbe84ca944c60cb926bfeb37fccf8975b4f048 /kernel
parentbpf: Fix subprog names in stack traces. (diff)
downloadlinux-a2a5580fcbf808e7c2310e4959b62f9d2157fdb6.tar.gz
linux-a2a5580fcbf808e7c2310e4959b62f9d2157fdb6.tar.bz2
linux-a2a5580fcbf808e7c2310e4959b62f9d2157fdb6.zip
bpf: Fix check against plain integer v 'NULL'
When checking with sparse, btf_show_type_value() is causing a warning about checking integer vs NULL when the macro is passed a pointer, due to the 'value != 0' check. Stop sparse complaining about any type-casting by adding a cast to the typeof(value). This fixes the following sparse warnings: kernel/bpf/btf.c:2579:17: warning: Using plain integer as NULL pointer kernel/bpf/btf.c:2581:17: warning: Using plain integer as NULL pointer kernel/bpf/btf.c:3407:17: warning: Using plain integer as NULL pointer kernel/bpf/btf.c:3758:9: warning: Using plain integer as NULL pointer Signed-off-by: Ben Dooks <ben.dooks@sifive.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20220714100322.260467-1-ben.dooks@sifive.com
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/btf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 4423045b8ff3..5869f03bcb6e 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -1116,7 +1116,8 @@ __printf(2, 3) static void btf_show(struct btf_show *show, const char *fmt, ...)
*/
#define btf_show_type_value(show, fmt, value) \
do { \
- if ((value) != 0 || (show->flags & BTF_SHOW_ZERO) || \
+ if ((value) != (__typeof__(value))0 || \
+ (show->flags & BTF_SHOW_ZERO) || \
show->state.depth == 0) { \
btf_show(show, "%s%s" fmt "%s%s", \
btf_show_indent(show), \