Re: [PATCH v2] tracing: Make is_signed_type() compatible with sparse
From: David Laight
Date: Wed Sep 02 2026 - 04:27:04 EST
On Tue, 1 Sep 2026 19:25:23 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> On Tue, 1 Sep 2026 14:56:01 -0700
> Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> >
> > 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
>
> It originally did but was changed to 1 for exactly that reason [1].
FWIW I suspect the 1 doesn't need a cast.
And I think the warning for (unsigned_var < 0) is currently disabled
because of too many annoying false positives.
(Thinks... (x >= 0) and (x < 0) could be treated differently!)
> > 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.
>
> Yeah, it was originally used for the tracing format files so that
> tooling can know how to display the raw values it parses. Also it is
> used for the filtering logic to know how to compare to the raw values.
And, in this case, the value is __bitwise so the 'tooling' doesn't know
how to display/compare them and you get a compile error.
Doesn't seem wrong :-)
David
>
> I see is_signed_type() has picked up some use cases outside of tracing,
> so I'm not sure how much those other areas care about things like
> "bool".
>
> -- Steve
>
>
> [1] d2802d0739dcc ("tracing: Compare to 1 instead of zero for is_signed_type()")
>