lkml.org 
[lkml]   [2022]   [Aug]   [25]   [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 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

\
 
 \ /
  Last update: 2022-08-25 09:58    [W:0.117 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site