* [PATCH seccomp] selftests/seccomp: Fix compile warning when CC=clang
@ 2022-05-26 22:34 YiFei Zhu
2022-05-27 20:34 ` Kees Cook
0 siblings, 1 reply; 2+ messages in thread
From: YiFei Zhu @ 2022-05-26 22:34 UTC (permalink / raw)
To: Kees Cook
Cc: Andy Lutomirski, Will Drewry, Shuah Khan, Christian Brauner,
linux-kselftest, bpf, llvm, YiFei Zhu
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: 3932fcecd962 ("selftests/seccomp: Add test for unknown SECCOMP_RET kill behavior")
Signed-off-by: YiFei Zhu <zhuyifei@google.com>
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 136df5b76319..4ae6c8991307 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -809,7 +809,7 @@ void kill_thread_or_group(struct __test_metadata *_metadata,
.len = (unsigned short)ARRAY_SIZE(filter_thread),
.filter = filter_thread,
};
- int kill = kill_how == KILL_PROCESS ? SECCOMP_RET_KILL_PROCESS : 0xAAAAAAAAA;
+ int kill = kill_how == KILL_PROCESS ? SECCOMP_RET_KILL_PROCESS : 0xAAAAAAAA;
struct sock_filter filter_process[] = {
BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
offsetof(struct seccomp_data, nr)),
--
2.36.1.124.g0e6072fb45-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH seccomp] selftests/seccomp: Fix compile warning when CC=clang
2022-05-26 22:34 [PATCH seccomp] selftests/seccomp: Fix compile warning when CC=clang YiFei Zhu
@ 2022-05-27 20:34 ` Kees Cook
0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2022-05-27 20:34 UTC (permalink / raw)
To: zhuyifei; +Cc: Kees Cook, shuah, luto, wad, bpf, brauner, llvm, linux-kselftest
On Thu, 26 May 2022 22:34:07 +0000, YiFei Zhu wrote:
> 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.
>
> [...]
Applied to for-next/seccomp, thanks!
[1/1] selftests/seccomp: Fix compile warning when CC=clang
https://git.kernel.org/kees/c/73a8dbafd31a
--
Kees Cook
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-27 20:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 22:34 [PATCH seccomp] selftests/seccomp: Fix compile warning when CC=clang YiFei Zhu
2022-05-27 20:34 ` Kees Cook
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.