public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* sparse warning about endianness mismatch on 0xffff assignment
@ 2015-04-16  6:04 Sathya Perla
  2015-04-16 20:57 ` Al Viro
  0 siblings, 1 reply; 2+ messages in thread
From: Sathya Perla @ 2015-04-16  6:04 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: sparse warning about endianness mismatch on 0xffff assignment
  2015-04-16  6:04 sparse warning about endianness mismatch on 0xffff assignment Sathya Perla
@ 2015-04-16 20:57 ` Al Viro
  0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2015-04-16 20:57 UTC (permalink / raw)
  To: Sathya Perla; +Cc: linux-kernel@vger.kernel.org

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-16 20:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-16  6:04 sparse warning about endianness mismatch on 0xffff assignment Sathya Perla
2015-04-16 20:57 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox