diff options
| author | Yonghong Song <[email protected]> | 2021-12-09 05:04:03 +0000 |
|---|---|---|
| committer | Andrii Nakryiko <[email protected]> | 2021-12-09 07:05:26 +0000 |
| commit | b540358e6c4d86eb450f3539aea198653e656641 (patch) | |
| tree | 31b77748a458c8fe9b4f5ad2e294907095ecd5b2 /tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c | |
| parent | perf/bpf_counter: Use bpf_map_create instead of bpf_create_map (diff) | |
| download | kernel-b540358e6c4d86eb450f3539aea198653e656641.tar.gz kernel-b540358e6c4d86eb450f3539aea198653e656641.zip | |
selftests/bpf: Fix a compilation warning
The following warning is triggered when I used clang compiler
to build the selftest.
/.../prog_tests/btf_dedup_split.c:368:6: warning: variable 'btf2' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!ASSERT_OK(err, "btf_dedup"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/.../prog_tests/btf_dedup_split.c:424:12: note: uninitialized use occurs here
btf__free(btf2);
^~~~
/.../prog_tests/btf_dedup_split.c:368:2: note: remove the 'if' if its condition is always false
if (!ASSERT_OK(err, "btf_dedup"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/.../prog_tests/btf_dedup_split.c:343:25: note: initialize the variable 'btf2' to silence this warning
struct btf *btf1, *btf2;
^
= NULL
Initialize local variable btf2 = NULL and the warning is gone.
Fixes: 9a49afe6f5a5 ("selftests/bpf: Add btf_dedup case with duplicated structs within CU")
Signed-off-by: Yonghong Song <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c index 878a864dae3b..90aac437576d 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c +++ b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c @@ -340,7 +340,7 @@ static void btf_add_dup_struct_in_cu(struct btf *btf, int start_id) static void test_split_dup_struct_in_cu() { - struct btf *btf1, *btf2; + struct btf *btf1, *btf2 = NULL; int err; /* generate the base data.. */ |
