Re: [PATCH v2] tracing: Make is_signed_type() compatible with sparse

From: Linus Torvalds

Date: Tue Sep 01 2026 - 18:03:22 EST


On Tue, 1 Sept 2026 at 14:43, Bart Van Assche <bvanassche@xxxxxxx> wrote:
>
> The only generic way I know of to remove the __bitwise marker is by
> using _Generic(). But that approach has been rejected by Linus.

Note that what I rejected was the "check for signedness using
_Generic()". I think that's both disgusting and fragile, because it
just lists a random number of types and then a "default: false".

IOW, that use of _Generic() is just *wrong*. It would perfectly
happily take a 'float', and say that it's not signed - no warnings
anywhere. Now, we don't have that in the kernel, but it's a random
example of why that complicated macro is garbage.

In contrast, the existing macro is *not* garbage. It just says "does
casting -1 end up being larger than casting 1". Admittedly it *should*
cast 0, but then compilers are unhappy about comparing unsigned values
against zero, so it's not great, but it's *simple*. It still gives
random results for 'bool', I guess, but is bool signed? I don't know,
I don't care. So at least it's simple and not clearly broken like the
_Generic() case is.

So I think the right thing to do is to make sparse happy with that
expression. _Generic() is *WRONG*.

This has absolutely nothing to do with "removing __bitwise". Because
__bitwise shouldn't be removed.

Linus