aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/trace_helpers.c
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2022-01-27 08:37:26 -0800
committerAlexei Starovoitov <ast@kernel.org>2022-01-27 09:48:49 -0800
commitcdb5ed9796e70ca666863eff65cf4907da5fe13c (patch)
treefbdc6384385845efd265b47c5199c3da4549c241 /tools/testing/selftests/bpf/trace_helpers.c
parentselftests, xsk: Fix bpf_res cleanup test (diff)
downloadlinux-dev-cdb5ed9796e70ca666863eff65cf4907da5fe13c.tar.xz
linux-dev-cdb5ed9796e70ca666863eff65cf4907da5fe13c.zip
selftests/bpf: fix a clang compilation error
When building selftests/bpf with clang make -j LLVM=1 make -C tools/testing/selftests/bpf -j LLVM=1 I hit the following compilation error: trace_helpers.c:152:9: error: variable 'found' is used uninitialized whenever 'while' loop exits because its condition is false [-Werror,-Wsometimes-uninitialized] while (fscanf(f, "%zx-%zx %s %zx %*[^\n]\n", &start, &end, buf, &base) == 4) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ trace_helpers.c:161:7: note: uninitialized use occurs here if (!found) ^~~~~ trace_helpers.c:152:9: note: remove the condition if it is always true while (fscanf(f, "%zx-%zx %s %zx %*[^\n]\n", &start, &end, buf, &base) == 4) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 trace_helpers.c:145:12: note: initialize the variable 'found' to silence this warning bool found; ^ = false It is possible that for sane /proc/self/maps we may never hit the above issue in practice. But let us initialize variable 'found' properly to silence the compilation error. Signed-off-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/r/20220127163726.1442032-1-yhs@fb.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/trace_helpers.c')
-rw-r--r--tools/testing/selftests/bpf/trace_helpers.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c
index 65ab533c2516..ca6abae9b09c 100644
--- a/tools/testing/selftests/bpf/trace_helpers.c
+++ b/tools/testing/selftests/bpf/trace_helpers.c
@@ -142,7 +142,7 @@ ssize_t get_uprobe_offset(const void *addr)
{
size_t start, end, base;
char buf[256];
- bool found;
+ bool found = false;
FILE *f;
f = fopen("/proc/self/maps", "r");