Messages in this thread | | | Date | Thu, 25 Aug 2022 09:57:25 +0200 | Subject | Re: [for-linus][PATCH 01/10] tracing: Suppress sparse warnings triggered by is_signed_type() | From | Rasmus Villemoes <> |
| |
On 25/08/2022 02.40, Linus Torvalds wrote: > On Wed, Aug 24, 2022 at 5:30 PM Linus Torvalds > <torvalds@linux-foundation.org> wrote: >> >> Let me think about this. > > Actually, thinking about it, that was simple enough. > > -#define is_signed_type(type) (((type)(-1)) < (type)1) > +#define is_signed_type(type) (((type)(-1)) < (__force type)1) > > should work. > > It looks a bit odd, because we only force one side.
One can also make the RHS not be a null pointer constant with something like
(((t)(-1)) <= (1 ? (t)0 : (t)0))
In either case, we're a good way into "this needs a comment explaining why it's written precisely the way it is" territory.
Rasmus
| |