Skip to content

Commit 4c0b474

Browse files
tstellarKernel Patches Daemon
authored andcommitted
bpftool: Fix -Wuninitialized-const-pointer warnings with clang >= 21 v2
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 <[email protected]> Acked-by: Quentin Monnet <[email protected]>
1 parent 0821404 commit 4c0b474

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tools/bpf/bpftool/btf_dumper.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ static int dump_prog_id_as_func_ptr(const struct btf_dumper *d,
3838
__u32 info_len = sizeof(info);
3939
const char *prog_name = NULL;
4040
struct btf *prog_btf = NULL;
41-
struct bpf_func_info finfo;
41+
/* Initialize finfo to silence -Wuninitialized-const-pointer warning
42+
* in clang >= 21. */
43+
struct bpf_func_info finfo = {};
4244
__u32 finfo_rec_size;
4345
char prog_str[1024];
4446
int err;

tools/bpf/bpftool/prog.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,9 @@ static void profile_print_readings(void)
22622262

22632263
static char *profile_target_name(int tgt_fd)
22642264
{
2265-
struct bpf_func_info func_info;
2265+
/* Initialize func_info to silence -Wuninitialized-const-pointer
2266+
* warning in clang >= 21. */
2267+
struct bpf_func_info func_info = {};
22662268
struct bpf_prog_info info = {};
22672269
__u32 info_len = sizeof(info);
22682270
const struct btf_type *t;

0 commit comments

Comments
 (0)