lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251219221827.4efa210c@pumpkin>
Date: Fri, 19 Dec 2025 22:18:27 +0000
From: David Laight <david.laight.linux@...il.com>
To: Nathan Chancellor <nathan@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>, Nicolas Schier <nsc@...nel.org>,
 linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] kbuild: Only enable
 -Wtautological-constant-out-of-range-compare for W=2

On Fri, 19 Dec 2025 13:12:31 -0700
Nathan Chancellor <nathan@...nel.org> wrote:

> Hi David,
> 
> On Sun, Dec 14, 2025 at 01:15:28PM +0000, david.laight.linux@...il.com wrote:
> > From: David Laight <david.laight.linux@...il.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@...il.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...

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);
         |                                 ^
   drivers/gpu/drm/xe/xe_guc_klv_helpers.h:62:2: note: expanded from macro 'PREP_GUC_KLV_TAG'
      62 |         PREP_GUC_KLV_CONST(MAKE_GUC_KLV_KEY(TAG), MAKE_GUC_KLV_LEN(TAG))
         |         ^
   drivers/gpu/drm/xe/xe_guc_klv_helpers.h:38:20: note: expanded from macro 'PREP_GUC_KLV_CONST'
      38 |         (FIELD_PREP_CONST(GUC_KLV_0_KEY, (key)) | \
         |                           ^
   drivers/gpu/drm/xe/abi/guc_klvs_abi.h:36:35: note: expanded from macro 'GUC_KLV_0_KEY'
      36 | #define GUC_KLV_0_KEY                           (0xffffu << 16)

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.

But this all reminds me of a compiler I once used that would generate a
warning for 'constant in conditional context'.

	David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ