2015-04-16 06:05:15

by Sathya Perla

[permalink] [raw]
Subject: sparse warning about endianness mismatch on 0xffff assignment

Hi,

The following code causes a sparse warning about " incorrect type in assignment (different base types)"

__le16 var = 0xFFFF;


What would be the best way of fixing this warning?

a) __le16 var = cpu_to_le16(0xFFFF);
b) __le16 var = (__force __le16) 0xFFFF;
c) Ignore the warning and/or fix the sparse tool to not warn about endianness mismatch on an "all 1s" assignment

thanks,
-Sathya




2015-04-16 20:57:48

by Al Viro

[permalink] [raw]
Subject: Re: sparse warning about endianness mismatch on 0xffff assignment

On Thu, Apr 16, 2015 at 06:04:40AM +0000, Sathya Perla wrote:
> What would be the best way of fixing this warning?
>
> a) __le16 var = cpu_to_le16(0xFFFF);

That would do just fine - it's a constant expression, actually.