]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bpftool: Fix -Wuninitialized-const-pointer warnings with clang >= 21
authorTom Stellard <tstellar@redhat.com>
Wed, 17 Sep 2025 18:38:47 +0000 (11:38 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 19 Sep 2025 22:42:42 +0000 (15:42 -0700)
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
tools/bpf/bpftool/btf_dumper.c
tools/bpf/bpftool/prog.c

index 4e896d8a2416e9c48bca715338b2b68f4d6989fb..ff12628593aecdf0562ab43debfc67c6babcac1b 100644 (file)
@@ -38,7 +38,7 @@ static int dump_prog_id_as_func_ptr(const struct btf_dumper *d,
        __u32 info_len = sizeof(info);
        const char *prog_name = NULL;
        struct btf *prog_btf = NULL;
-       struct bpf_func_info finfo;
+       struct bpf_func_info finfo = {};
        __u32 finfo_rec_size;
        char prog_str[1024];
        int err;
index cf18c3879680141a8f3fed24bab0887dfc7c8a6f..4dccc75b0bab012bb8f3529f37cfec8fa7b11c75 100644 (file)
@@ -2262,7 +2262,7 @@ static void profile_print_readings(void)
 
 static char *profile_target_name(int tgt_fd)
 {
-       struct bpf_func_info func_info;
+       struct bpf_func_info func_info = {};
        struct bpf_prog_info info = {};
        __u32 info_len = sizeof(info);
        const struct btf_type *t;