Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: fix endian check warning in etherdevice.h

Sparse builds have been warning for a really long time now
that etherdevice.h has a conversion that is unsafe.

include/linux/etherdevice.h:79:32: warning: restricted __be16 degrades to integer

This code change fixes the issue and generates the exact
same assembly before/after (checked on x86_64)

Fixes: 2c722fe1c821 (etherdevice: Optimize a few is_<foo>_ether_addr functions)
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
CC: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jesse Brandeburg and committed by
David S. Miller
fbaff3ef f3ae683f

+1 -1
+1 -1
include/linux/etherdevice.h
··· 76 76 77 77 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 78 78 return (((*(const u32 *)addr) ^ (*(const u32 *)b)) | 79 - ((a[2] ^ b[2]) & m)) == 0; 79 + (__force int)((a[2] ^ b[2]) & m)) == 0; 80 80 #else 81 81 return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | ((a[2] ^ b[2]) & m)) == 0; 82 82 #endif