Skip to content

Commit 226935e

Browse files
zhuyifei1999gregkh
authored andcommitted
selftests/seccomp: Fix compile warning when CC=clang
[ Upstream commit 3ce4b78 ] 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: 3932fce ("selftests/seccomp: Add test for unknown SECCOMP_RET kill behavior") Signed-off-by: YiFei Zhu <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 7bc43ab commit 226935e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ void kill_thread_or_group(struct __test_metadata *_metadata,
802802
.len = (unsigned short)ARRAY_SIZE(filter_thread),
803803
.filter = filter_thread,
804804
};
805-
int kill = kill_how == KILL_PROCESS ? SECCOMP_RET_KILL_PROCESS : 0xAAAAAAAAA;
805+
int kill = kill_how == KILL_PROCESS ? SECCOMP_RET_KILL_PROCESS : 0xAAAAAAAA;
806806
struct sock_filter filter_process[] = {
807807
BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
808808
offsetof(struct seccomp_data, nr)),

0 commit comments

Comments
 (0)