Re: [PATCH] minmax.h: update the stale 'x' versus 'ux' comment

From: Andrew Morton

Date: Sat Aug 29 2026 - 19:42:58 EST


On Mon, 17 Aug 2026 20:16:13 +0800 Zhan Xusheng <zhanxusheng1024@xxxxxxxxx> wrote:

> From: Zhan Xusheng <zhanxusheng1024@xxxxxxxxx>
>
> From: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>

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