]> git.baikalelectronics.ru Git - kernel.git/commit
test_bpf: Fix a new clang warning about xor-ing two numbers
authorNathan Chancellor <natechancellor@gmail.com>
Mon, 19 Aug 2019 04:34:20 +0000 (21:34 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 20 Aug 2019 15:07:29 +0000 (17:07 +0200)
commitf52773555a26da86c5e283ec15aaef1de35b3654
treeaf8f67c7ead8d899d6ac2998ebe59413aac47a94
parent61ad212035abd29b69e9152a4ac4e2fb68c4ac15
test_bpf: Fix a new clang warning about xor-ing two numbers

r369217 in clang added a new warning about potential misuse of the xor
operator as an exponentiation operator:

../lib/test_bpf.c:870:13: warning: result of '10 ^ 300' is 294; did you
mean '1e300'? [-Wxor-used-as-pow]
                { { 4, 10 ^ 300 }, { 20, 10 ^ 300 } },
                       ~~~^~~~~
                       1e300
../lib/test_bpf.c:870:13: note: replace expression with '0xA ^ 300' to
silence this warning
../lib/test_bpf.c:870:31: warning: result of '10 ^ 300' is 294; did you
mean '1e300'? [-Wxor-used-as-pow]
                { { 4, 10 ^ 300 }, { 20, 10 ^ 300 } },
                                         ~~~^~~~~
                                         1e300
../lib/test_bpf.c:870:31: note: replace expression with '0xA ^ 300' to
silence this warning

The commit link for this new warning has some good logic behind wanting
to add it but this instance appears to be a false positive. Adopt its
suggestion to silence the warning but not change the code. According to
the differential review link in the clang commit, GCC may eventually
adopt this warning as well.

Link: https://github.com/ClangBuiltLinux/linux/issues/643
Link: https://github.com/llvm/llvm-project/commit/920890e26812f808a74c60ebc14cc636dac661c1
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
lib/test_bpf.c