[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8b8262389bd6484586007d749132346f@AcuMS.aculab.com>
Date: Wed, 4 Dec 2024 18:54:16 +0000
From: David Laight <David.Laight@...LAB.COM>
To: Vincent Mailhol <mailhol.vincent@...adoo.fr>, Linus Torvalds
<torvalds@...ux-foundation.org>, Luc Van Oostenryck
<luc.vanoostenryck@...il.com>, Nathan Chancellor <nathan@...nel.org>, "Nick
Desaulniers" <ndesaulniers@...gle.com>, Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>, Yury Norov <yury.norov@...il.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>, Kees Cook <kees@...nel.org>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>, Jani Nikula
<jani.nikula@...ux.intel.com>, Joonas Lahtinen
<joonas.lahtinen@...ux.intel.com>, Rodrigo Vivi <rodrigo.vivi@...el.com>,
Tvrtko Ursulin <tursulin@...ulin.net>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>, Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach <mike.leach@...aro.org>, James Clark <james.clark@...aro.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Rikard Falkeborn
<rikard.falkeborn@...il.com>, Martin Uecker
<Martin.Uecker@....uni-goettingen.de>
CC: "linux-sparse@...r.kernel.org" <linux-sparse@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"llvm@...ts.linux.dev" <llvm@...ts.linux.dev>,
"linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>,
"intel-gfx@...ts.freedesktop.org" <intel-gfx@...ts.freedesktop.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"coresight@...ts.linaro.org" <coresight@...ts.linaro.org>,
"linux-arm-kernel@...ts.infradead.org" <linux-arm-kernel@...ts.infradead.org>
Subject: RE: [PATCH 05/10] minmax: simplify __clamp_once() by using
is_const_false()
From: Vincent Mailhol
> Sent: 02 December 2024 17:33
>
> In __clamp_once(),
>
> __builtin_choose_expr(__is_constexpr((lo) > (hi)), (lo) <= (hi), true)
>
> is equivalent to:
>
> !is_const_false((lo) <= (hi))
>
> Apply is_const_false() to simplify __clamp_once().
There is already a patch 'for next' that changes it use BUILD_BUG_ON_MSG()
and statically_true().
It has found some 'interesting' code.
David
>
> Signed-off-by: Vincent Mailhol <mailhol.vincent@...adoo.fr>
> ---
> include/linux/minmax.h | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/include/linux/minmax.h b/include/linux/minmax.h
> index 98008dd92153db10c672155bca93201ffabee994..431bf76ac460a11a2e4af23acd90c0d26e99c862 100644
> --- a/include/linux/minmax.h
> +++ b/include/linux/minmax.h
> @@ -111,8 +111,7 @@
> __auto_type uval = (val); \
> __auto_type ulo = (lo); \
> __auto_type uhi = (hi); \
> - static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \
> - (lo) <= (hi), true), \
> + static_assert(!is_const_false((lo) <= (hi)), \
> "clamp() low limit " #lo " greater than high limit " #hi); \
> BUILD_BUG_ON_MSG(!__types_ok3(val,lo,hi,uval,ulo,uhi), \
> "clamp("#val", "#lo", "#hi") signedness error"); \
>
> --
> 2.45.2
>
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists