Bogus warning when comparing nocast short variables

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

 



Hello!

This test file causes a warning:

typedef short __attribute__((nocast)) u16;
int main(int argc, char **argv)
{
        u16 i = (u16)argc;
        u16 j = (u16)2;
        return (i == j);
}

$ sparse test1.c 
test1.c:6:17: warning: implicit cast from nocast type
test1.c:6:22: warning: implicit cast from nocast type

But this file doesn't cause any warning:

typedef short __attribute__((nocast)) u16;
int main(int argc, char **argv)
{
        u16 i = (u16)argc;
        u16 j = (u16)2;
        switch (i) {
                case j: return 1;;
                default: return 0;;
        }
}

I think the warnings are bogus.  No cast should be needed to compare
variables of the same type.

The warning was actually found in the current Linux kernel, driver
zd1121rw.  A fix was proposed, but I thing the fix belongs to the sparse
code.

-- 
Regards,
Pavel Roskin
--
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