Re: "unsigned expression < 0" always false warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2013-04-19 at 13:43 -0700, Gary Hade wrote:

> The above
>   "__field(        u32,            status          )"
> gets expanded to
>   "ret = trace_define_field(event_call, "u32", "status", __builtin_offsetof(typeof(field),status), sizeof(field.status), (((u32)(-1)) < (u32)0), FILTER_OTHER); if (ret) return ret;"
> 
> The warning is triggered by:
>   "(((u32)(-1)) < (u32)0)"
> which was put there by is_signed_type.
> 
> It appears that is_signed_type is simply taking advantage of the same
> action that the compiler is warning about to perform it's function.

Yeah, that's the point of the macro.

> 
> Not sure how to make is_signed_type warningless although
> it does create a significant amount of noise during a full
> `make W=1` kernel build.  With 3.9-rc7 it appears to be
> responsible for 1401 of 1476 occurrences of "warning: comparison
> of unsigned expression < 0 is always false".

Since it is complaining about being less than zero, I just checked, the
following also works.

#define is_signed_type(type) ((type)-1 < (type)1)

And doesn't give the warning.

I'll go make a patch.

Thanks!

-- Steve


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux