]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/seccomp: Fix compile warning when CC=clang
authorYiFei Zhu <zhuyifei@google.com>
Thu, 26 May 2022 22:34:07 +0000 (22:34 +0000)
committerKees Cook <keescook@chromium.org>
Wed, 27 Jul 2022 19:12:16 +0000 (12:12 -0700)
commit362492dac394d8316103787506b4dff8c88a475f
treeaaef2a005cc1372ac5aa8ecd858ac2ce3b3f4c75
parent08aafa0d475a08e31a13403e9df41c7179f4bdcd
selftests/seccomp: Fix compile warning when CC=clang

clang has -Wconstant-conversion by default, and the constant 0xAAAAAAAAA
(9 As) being converted to an int, which is generally 32 bits, results
in the compile warning:

  clang -Wl,-no-as-needed -Wall -isystem ../../../../usr/include/  -lpthread  seccomp_bpf.c -lcap -o seccomp_bpf
  seccomp_bpf.c:812:67: warning: implicit conversion from 'long' to 'int' changes value from 45812984490 to -1431655766 [-Wconstant-conversion]
          int kill = kill_how == KILL_PROCESS ? SECCOMP_RET_KILL_PROCESS : 0xAAAAAAAAA;
              ~~~~                                                         ^~~~~~~~~~~
  1 warning generated.

-1431655766 is the expected truncation, 0xAAAAAAAA (8 As), so use
this directly in the code to avoid the warning.

Fixes: 96ae5931f586 ("selftests/seccomp: Add test for unknown SECCOMP_RET kill behavior")
Signed-off-by: YiFei Zhu <zhuyifei@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220526223407.1686936-1-zhuyifei@google.com
tools/testing/selftests/seccomp/seccomp_bpf.c