Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpftool: Fix -Wuninitialized-const-pointer warnings with clang >= 21

This fixes the build with -Werror -Wall.

btf_dumper.c:71:31: error: variable 'finfo' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
71 | info.func_info = ptr_to_u64(&finfo);
| ^~~~~

prog.c:2294:31: error: variable 'func_info' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
2294 | info.func_info = ptr_to_u64(&func_info);
|

v2:
- Initialize instead of using memset.

Signed-off-by: Tom Stellard <tstellar@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20250917183847.318163-1-tstellar@redhat.com

authored by

Tom Stellard and committed by
Andrii Nakryiko
5612ea8b 57cb2695

+2 -2
+1 -1
tools/bpf/bpftool/btf_dumper.c
··· 38 38 __u32 info_len = sizeof(info); 39 39 const char *prog_name = NULL; 40 40 struct btf *prog_btf = NULL; 41 - struct bpf_func_info finfo; 41 + struct bpf_func_info finfo = {}; 42 42 __u32 finfo_rec_size; 43 43 char prog_str[1024]; 44 44 int err;
+1 -1
tools/bpf/bpftool/prog.c
··· 2262 2262 2263 2263 static char *profile_target_name(int tgt_fd) 2264 2264 { 2265 - struct bpf_func_info func_info; 2265 + struct bpf_func_info func_info = {}; 2266 2266 struct bpf_prog_info info = {}; 2267 2267 __u32 info_len = sizeof(info); 2268 2268 const struct btf_type *t;