Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE44F1384 for ; Thu, 26 May 2022 22:34:22 +0000 (UTC) Received: by mail-pj1-f74.google.com with SMTP id nn14-20020a17090b38ce00b001e00df82de8so4002247pjb.1 for ; Thu, 26 May 2022 15:34:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=Dbycd53wfkFx6wOlXEkeKq8SwIpffLRDpImC05lVbps=; b=j+SEgTICldnd/BNzVi+sD0qfYmtFOB70dPvJ9XXrAwUJ3rxqVCeHCkGBYHZ7uMugGw RsLQrLCnS0E+oS5rjDsPC6MKuYaSXuomFh7GVRykVXWZ0lhx93/r3ckTobcrRa5AZxZk Sd5Eh667uybkWyKhpA5NFw13I8HjlDnvDnh9vuhLH5MOebh1aadDBoD5Zcal4ZxYV0LT S/v7ZNF2c224Ll6Yg2xhkX2fwxJShoqxAYZNf32/RM6n99XUWGvig1Bq3lVVfh8GObvj psdKBDigEhzO4d84B6dXa2N733ZQTfbo3K7fRU8FuOodJjDDIcSYInblsc1XftrHYoWX Pt/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Dbycd53wfkFx6wOlXEkeKq8SwIpffLRDpImC05lVbps=; b=dlSg8Ybx15X9UJBcrgn6vdRuONoCli3dQXDe+qsLJawQfej7nRYzx9Q22ps/PZO8bt 4SxNLcITuf9wxXYS1wN/ofXPQc2UI0FtUYPbGTAta3teG+JaaNFdGNX7ZaYiHkBP3yXE BduzJC6CQP+W1RgvxS2HRaZ0x+HhCFwafxGP3mulSt1xQf5bXdr0wVBOSBE4l/9q1C2G rBUNkcvkwo3fatWqpf9F0EACXuwY8tJGSqCyRfFbX03NOhsqLvWcdiDLo1b7uPduo2eY APBfaxRqQH8QzHUU5+X/9mu9ocE69hlZngB5l3CFwsyKJQ6hMsrs6lIGEmEIrqnoWReg 1WwA== X-Gm-Message-State: AOAM5338xc5D84j52eZZml6DlhuuayyCAZG4wy/mbZBeyKE8L819G8XI oVAwwm9egCBMja8/xiITI6QAuXtwC/yUGw== X-Google-Smtp-Source: ABdhPJxB1e3fXG0Ot53wI1nKFx+/5VDP4vCejcIdEzde3KgllVaDKk6peAdB4F6WdN2YyEq+pIVc3TjUgcFuHA== X-Received: from zhuyifei-kvm.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2edc]) (user=zhuyifei job=sendgmr) by 2002:a17:903:213:b0:162:15c2:e4b5 with SMTP id r19-20020a170903021300b0016215c2e4b5mr25653760plh.114.1653604461947; Thu, 26 May 2022 15:34:21 -0700 (PDT) Date: Thu, 26 May 2022 22:34:07 +0000 Message-Id: <20220526223407.1686936-1-zhuyifei@google.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [PATCH seccomp] selftests/seccomp: Fix compile warning when CC=clang From: YiFei Zhu To: Kees Cook Cc: Andy Lutomirski , Will Drewry , Shuah Khan , Christian Brauner , linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev, YiFei Zhu Content-Type: text/plain; charset="UTF-8" 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 --- 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