From: Nathan Chancellor <nathan@kernel.org>
To: david.laight.linux@gmail.com
Cc: Arnd Bergmann <arnd@arndb.de>, Nicolas Schier <nsc@kernel.org>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] kbuild: Only enable -Wtautological-constant-out-of-range-compare for W=2
Date: Fri, 19 Dec 2025 13:12:31 -0700 [thread overview]
Message-ID: <20251219201231.GB1404453@ax162> (raw)
In-Reply-To: <20251214131528.3648-1-david.laight.linux@gmail.com>
Hi David,
On Sun, Dec 14, 2025 at 01:15:28PM +0000, david.laight.linux@gmail.com wrote:
> From: David Laight <david.laight.linux@gmail.com>
>
> The kernel code style is to use !(expr) rather that (expr) == 0.
> But clang complains that converting some constant expressions
> (eg (0xffffu << 16)) to a boolean always evalutes to true.
> This happens often in the validity checks in #defines.
> Move tautological-constant-out-of-range-compare to W=2 (along with the
> similar type-limits).
>
> Signed-off-by: David Laight <david.laight.linux@gmail.com>
I would like Arnd to comment on this before applying because the
reasoning of this change does not feel good enough to disable this
warning. It is not like '== 0' is inherently uncommon in the kernel or
hard to write to avoid the implicit conversion warning. To be honest, I
am a bit surprised -Wtautological-constant-out-of-range-compare fires
for that instead of some sort of -Wconversion warning...
> ---
> scripts/Makefile.warn | 2 +-I
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn
> index 68e6fafcb80c..e2d467835c5b 100644
> --- a/scripts/Makefile.warn
> +++ b/scripts/Makefile.warn
> @@ -151,7 +151,6 @@ KBUILD_CFLAGS += -Wformat-insufficient-args
> endif
> endif
> KBUILD_CFLAGS += $(call cc-option, -Wno-pointer-to-enum-cast)
> -KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
> KBUILD_CFLAGS += $(call cc-option, -Wno-unaligned-access)
> KBUILD_CFLAGS += -Wno-enum-compare-conditional
> endif
> @@ -179,6 +178,7 @@ KBUILD_CFLAGS += -Wno-shift-negative-value
>
> ifdef CONFIG_CC_IS_CLANG
> KBUILD_CFLAGS += -Wno-enum-enum-conversion
> +KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
> endif
>
> ifdef CONFIG_CC_IS_GCC
> --
> 2.39.5
>
next prev parent reply other threads:[~2025-12-19 20:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-14 13:15 [PATCH 1/1] kbuild: Only enable -Wtautological-constant-out-of-range-compare for W=2 david.laight.linux
2025-12-19 20:12 ` Nathan Chancellor [this message]
2025-12-19 20:26 ` Arnd Bergmann
2025-12-19 22:18 ` David Laight
2025-12-20 10:27 ` Arnd Bergmann
2025-12-20 12:15 ` David Laight
2025-12-22 10:20 ` Arnd Bergmann
2025-12-22 17:14 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251219201231.GB1404453@ax162 \
--to=nathan@kernel.org \
--cc=arnd@arndb.de \
--cc=david.laight.linux@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nsc@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.