Re: [PATCH 4/7] minmax: Simplify signedness check

Linus Torvalds
2024-07-24T20:03:09Z

On Wed, 24 Jul 2024 at 09:49, Arnd Bergmann <arnd@kernel.org> wrote:
>
> I don't understand why this return '0' for unsigned types,
> shouldn't this be
>
> ((is_unsigned_type(typeof(x)) ? 1 : __if_constexpr(x, (x) + 0, -1)) >= 0)

Yes, that looks more logical.

Plus why do that "__if_constexpr(x, (x) + 0, -1)) >= 0)" when it would
appear to be more logical to move the comparison inside, ie

__if_constexpr(x, (x) >= 0, 0)

but I also don't see why that "+ 0" existed in the original. So
there's presumably something I'm missing.

I do get the feeling that the problem came from us being much too
clever with out min/max macros, and now this series is doubling down
instead of saying "it wasn't really worth it".

Linus