Re: [PATCH] sparse: Make struct token::special signed

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

 



On Wed, Dec 24 2014, Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> wrote:

> On Tue, 2014-12-23 at 11:01 -0800, Linus Torvalds wrote:
>> On Tue, Dec 23, 2014 at 5:16 AM, Rasmus Villemoes <rv@xxxxxxxxxxxxxxxxxx> wrote:
>> > There doesn't seem to be any reason for the special member of struct
>> > token to be unsigned; AFAICT it is only ever being directly compared
>> > to explicit characters and the SPECIAL_* enum constants using ==, !=
>> > and in a switch statement. Making it plain int avoids an annoying
>> > warning from match_op in token.h when compiling with -Wsign-compare.
>> 
>> Please don't use -Wsign-cpmpare to make decisions about code.
>> 
>> "unsigned" is generally the much preferred type if there are no
>> reasons for it to be signed. And -Wsign-compare on its own is not a
>> reason, since it gives insane warnings for good code.
>> 
>> -Wsign-compare is basically a "you can walk through the warnings and
>> see if any of them are actually valid" thing. It's not worth it in any
>> other form. Trying to be sign-compare clean will result in actively
>> *worse* code in some circumstances (ie pointless casts etc etc).
>
> Additionally "compare with characters" trips another flag, chars are
> unsigned by default on some archs :)

And signed on others... if anything, that seems to be an argument _for_
the patch, since an int can always represent the entire range of char,
while that is not true for unsigned.

Anyway, I'm not going to pursue this further.

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



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux