From: Andrew Morton <akpm@linux-foundation.org>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: David Laight <david.laight.linux@gmail.com>,
"H . Peter Anvin" <hpa@zytor.com>,
zhanxusheng@xiaomi.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] minmax.h: update the stale 'x' versus 'ux' comment
Date: Sat, 29 Aug 2026 16:42:49 -0700 [thread overview]
Message-ID: <20260829164249.78372631e4424a07bcf8c9da@linux-foundation.org> (raw)
In-Reply-To: <20260817121613.3846511-1-zhanxusheng@xiaomi.com>
On Mon, 17 Aug 2026 20:16:13 +0800 Zhan Xusheng <zhanxusheng1024@gmail.com> wrote:
> From: Zhan Xusheng <zhanxusheng1024@gmail.com>
>
> From: Zhan Xusheng <zhanxusheng@xiaomi.com>
Well that's confusing ;)
I'll assume @xiaomi.com was intended.
> Commit b280bb27a9f7 ("minmax.h: reduce the #define expansion of min(),
> max() and clamp()") made __sign_use(), __is_nonneg() and __types_ok() take
> only 'ux', and commit a5743f32baec ("minmax.h: use BUILD_BUG_ON_MSG() for
> the lo < hi test in clamp()") did the same for the clamp() limit test. The
> comment describing the old split was added one patch earlier and was never
> updated.
>
> 'ux' now carries the value check too, since __is_nonneg() tests it rather
> than the original expression, and nothing here looks at the value of 'x'
> any more: it is expanded only to initialise 'ux' and in the error message,
> as the first of those changes intended.
>
Thanks.
> --- a/include/linux/minmax.h
> +++ b/include/linux/minmax.h
> @@ -38,9 +38,9 @@
> * Note that 'x' is the original expression, and 'ux' is the unique variable
> * that contains the value.
> *
> - * We use 'ux' for pure type checking, and 'x' for when we need to look at the
> - * value (but without evaluating it for side effects!
> - * Careful to only ever evaluate it with sizeof() or __builtin_constant_p() etc).
> + * We use 'ux' for both the type and the value checks, so 'x' itself is only
> + * expanded twice: once to initialise 'ux', and once quoted in the error
> + * message.
> *
> * Pointers end up being checked by the normal C type rules at the actual
> * comparison, and these expressions only need to be careful to not cause
prev parent reply other threads:[~2026-08-29 23:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 12:16 Zhan Xusheng
2026-08-29 23:42 ` Andrew Morton [this message]
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=20260829164249.78372631e4424a07bcf8c9da@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=david.laight.linux@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.com \
/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
all inboxes | Powered by JetHome®