enums and EXPR_VALUE and sign expansion

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

 



I'm upgrading to the latest version of Sparse and it's mostly been easy
and full of improvements but I'm running into one issue:

The problem is that if you have:

enum {
	a = 0x80000000,
	b = -1,
}

Then Sparse doesn't handle that correctly and it leads to a false
positive in Smatch.

drivers/scsi/stex.c:1879 stex_hba_stop() warn: always true condition '(st_sleep_mic != 4294967295) => (s32min-s32max != 4294967295)'

In GCC the enum would be a signed int, but in Sparse it is a signed
long (on my 64 bit system).  That would be fine except the second issue
is the signed bit isn't expanded correctly because a long -1 should be
0xffffffffffffffff and the expr->value is 0xffffffff.

regards,
dan carpenter





[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