Skip to content

Commit 34ec1f5

Browse files
tstellarKernel Patches Daemon
authored andcommitted
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); | Signed-off-by: Tom Stellard <[email protected]>
1 parent 2b3c471 commit 34ec1f5

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

tools/bpf/bpftool/btf_dumper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ static int dump_prog_id_as_func_ptr(const struct btf_dumper *d,
6868
memset(&info, 0, sizeof(info));
6969
info.nr_func_info = 1;
7070
info.func_info_rec_size = finfo_rec_size;
71+
/* Silence -Wuninitialized-const-pointer warning in clang >= 21. */
72+
memset(&finfo, 0, sizeof(finfo));
7173
info.func_info = ptr_to_u64(&finfo);
7274

7375
err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);

tools/bpf/bpftool/prog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,8 @@ static char *profile_target_name(int tgt_fd)
22912291
memset(&info, 0, sizeof(info));
22922292
info.nr_func_info = 1;
22932293
info.func_info_rec_size = func_info_rec_size;
2294+
/* Silence -Wuninitialized-const-pointer warning in clang >= 21. */
2295+
memset(&func_info, 0, sizeof(func_info));
22942296
info.func_info = ptr_to_u64(&func_info);
22952297

22962298
err = bpf_prog_get_info_by_fd(tgt_fd, &info, &info_len);

0 commit comments

Comments
 (0)