selftests/bpf: Fix build error due to certain uninitialized variables
authorYonghong Song <yonghong.song@linux.dev>
Tue, 15 Jul 2025 18:59:10 +0000 (11:59 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 15 Jul 2025 21:38:58 +0000 (14:38 -0700)
commite860a98c8aebd8de82c0ee901acf5a759acd4570
tree9683f886addf6145d0370f9b80fad3aeb5da2391
parentea2aecdf7a954a8c0015e185cc870c4191d1d93f
selftests/bpf: Fix build error due to certain uninitialized variables

With the latest llvm21 compiler, I hit several errors when building bpf
selftests. Some of errors look like below:

  test_maps.c:565:40: error: variable 'val' is uninitialized when passed as a
      const pointer argument here [-Werror,-Wuninitialized-const-pointer]
    565 |         assert(bpf_map_update_elem(fd, NULL, &val, 0) < 0 &&
        |                                               ^~~

  prog_tests/bpf_iter.c:400:25: error: variable 'c' is uninitialized when passed
      as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
  400 |         write(finish_pipe[1], &c, 1);
      |                                ^

Some other errors have similar the pattern as the above.

These errors are fixed by initializing those variables properly.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250715185910.3659447-1-yonghong.song@linux.dev
tools/testing/selftests/bpf/prog_tests/bloom_filter_map.c
tools/testing/selftests/bpf/prog_tests/bpf_iter.c
tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
tools/testing/selftests/bpf/prog_tests/verify_pkcs7_sig.c
tools/testing/selftests/bpf/test_maps.c