lkml.org 
[lkml]   [2022]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [for-linus][PATCH 01/10] tracing: Suppress sparse warnings triggered by is_signed_type()
From
On 8/23/22 00:06, Rasmus Villemoes wrote:
> On 22/08/2022 20.45, Linus Torvalds wrote:
>> But we did have a sparse fix for it, didn't we? That fix required that
>> the '< (type)1' cast be changed to '<= (type)0' iirc, and a patch to
>> sparse, but it at least avoided the problem.
>
> Heh. I originally wrote the comparison "< (t)1" instead of "< (t)0" to
> avoid a -Wtype-limits warning when applied to unsigned types - yeah
> yeah, the kernel isn't built with that, but it's a nice macro to
> copy-paste to other projects, and sometimes people do explicitly enable
> -Wtype-limits to manually go through some, and then it's nice to not
> have tons of false positives from this macro.
>
> But of course <1 is the same as <=0, and we can indeed spell it that way
> without triggering Wtype-limits. So if that can help with also silencing
> sparse, ack from me on that part.

Thank you Rasmus for having shared this information. Since sparse will
have to be modified anyway, how about extending it such that the bitwise
attribute can be removed from a type, e.g. via a new no_bitwise
attribute? Wouldn't that be a more generic solution than only
suppressing sparse complaints when comparing compile-time constants and
when the left-hand-side and right-hand-side have different bitwise
attributes? For reference purposes, this is how __bitwise is defined:

#ifdef __CHECKER__
#define __bitwise __attribute__((bitwise))
#else
#define __bitwise
#endif

Thanks,

Bart.

\
 
 \ /
  Last update: 2022-08-24 00:07    [W:0.294 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site