diff options
author | Yonghong Song <yhs@fb.com> | 2022-03-10 16:37:21 -0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2022-03-11 22:18:13 +0100 |
commit | d3b351f65bf42ccda1f686de3ccb21ea1a0c4f5a (patch) | |
tree | dff0fa15f56becacd32895844eecc96bcb3e569c /lib/locking-selftest.c | |
parent | c09df4bd3a915079eec5e77160366225a28699a2 (diff) | |
download | lwn-d3b351f65bf42ccda1f686de3ccb21ea1a0c4f5a.tar.gz lwn-d3b351f65bf42ccda1f686de3ccb21ea1a0c4f5a.zip |
selftests/bpf: Fix a clang compilation error for send_signal.c
Building selftests/bpf with latest clang compiler (clang15 built
from source), I hit the following compilation error:
/.../prog_tests/send_signal.c:43:16: error: variable 'j' set but not used [-Werror,-Wunused-but-set-variable]
volatile int j = 0;
^
1 error generated.
The problem also exists with clang13 and clang14. clang12 is okay.
In send_signal.c, we have the following code ...
volatile int j = 0;
[...]
for (int i = 0; i < 100000000 && !sigusr1_received; i++)
j /= i + 1;
... to burn CPU cycles so bpf_send_signal() helper can be tested
in NMI mode.
Slightly changing 'j /= i + 1' to 'j /= i + j + 1' or 'j++' can
fix the problem. Further investigation indicated this should be
a clang bug ([1]). The upstream fix will be proposed later. But it
is a good idea to workaround the issue to unblock people who build
kernel/selftests with clang.
[1] https://discourse.llvm.org/t/strange-clang-unused-but-set-variable-error-with-volatile-variables/60841
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220311003721.2177170-1-yhs@fb.com
Diffstat (limited to 'lib/locking-selftest.c')
0 files changed, 0 insertions, 0 deletions