Messages in this thread | | | Date | Tue, 23 Aug 2022 09:06:50 +0200 | Subject | Re: [for-linus][PATCH 01/10] tracing: Suppress sparse warnings triggered by is_signed_type() | From | Rasmus Villemoes <> |
| |
On 22/08/2022 20.45, Linus Torvalds wrote: > On Mon, Aug 22, 2022 at 11:20 AM Bart Van Assche <bvanassche@acm.org> wrote: >> >> I agree that it's better that sparse sees the same code as what is used to >> build the kernel. However, I do not agree that the patch above is a solution. >> Sparse reports a warning for the suggested definition above of is_signed_type() >> because the new definition tries to use the less-than (<) operator to compare >> two __bitwise types. > > Argh. I forgot that part. It wasn't just the cast that warned, it was > the compare too. > > 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.
Rasmus
| |