Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "David Laight" <david.laight.linux@gmail.com>,
	"Nathan Chancellor" <nathan@kernel.org>
Cc: "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: Sat, 20 Dec 2025 11:27:13 +0100	[thread overview]
Message-ID: <40f1457c-6e57-4d09-b50e-7133bafa7c3e@app.fastmail.com> (raw)
In-Reply-To: <20251219221827.4efa210c@pumpkin>

On Fri, Dec 19, 2025, at 23:18, David Laight wrote:
> On Fri, 19 Dec 2025 13:12:31 -0700 Nathan Chancellor <nathan@kernel.org> wrote:
>
> Somewhere I got confused and must have looked at the wrong email (or just
> failed to separate two very long warning names).
> The actual warning was:
>
>>> drivers/gpu/drm/xe/xe_guc.c:639:19: error: converting the result of '<<' to a boolean always evaluates to true [-Werror,-Wtautological-constant-compare]  
>      639 |                 klvs[count++] = 
> PREP_GUC_KLV_TAG(OPT_IN_FEATURE_EXT_CAT_ERR_TYPE);

This does seem like a completely sensible warning to me, and it's
always been enabled by default. I see three patches in the git history
(all from Nathan), which all make sense as well.

> Inside FIELD_PREP_CONST(mask, val) there is (with the patch, and if I've
> typed it correctly):
> 	BUILD_BUG_ON_ZERO(!(mask) || (mask) & ((mask) + ((mask) & -(mask)))))
> to check the mask is non-zero and contiguous bits.

I think the problem is (as so often) the linux/bitfield.h headers
making things way too complicated. That condition makes no sense to
me, and neither would I expect a compiler to make sense of it either.

If there is no way to express those conditions more clearly, I would
prefer removing the BUILD_BUG_ON stuff from the bitfield.h header,
it keeps causing way more false positives than finding actual bugs
with the input.

     Arnd

  reply	other threads:[~2025-12-20 10:27 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
2025-12-19 20:26   ` Arnd Bergmann
2025-12-19 22:18   ` David Laight
2025-12-20 10:27     ` Arnd Bergmann [this message]
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=40f1457c-6e57-4d09-b50e-7133bafa7c3e@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=david.laight.linux@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox