]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
lib: Fix generic strnlen_user for 32-bit big-endian machines
authorPaul Mackerras <paulus@samba.org>
Mon, 28 May 2012 02:59:56 +0000 (12:59 +1000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 28 May 2012 03:59:46 +0000 (20:59 -0700)
The aligned_byte_mask() definition is wrong for 32-bit big-endian
machines: the "7-(n)" part of the definition assumes a long is 8
bytes.  This fixes it by using BITS_PER_LONG - 8 instead of 8*7.
Tested on 32-bit and 64-bit PowerPC.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/strnlen_user.c

index 90900ecfeb542f361dd0785b99f746f0a8c4ed23..a28df5206d95c24d6f3b4116753747f1fb2a67e3 100644 (file)
@@ -8,7 +8,7 @@
 #ifdef __LITTLE_ENDIAN
 #  define aligned_byte_mask(n) ((1ul << 8*(n))-1)
 #else
-#  define aligned_byte_mask(n) (~0xfful << 8*(7-(n)))
+#  define aligned_byte_mask(n) (~0xfful << (BITS_PER_LONG - 8 - 8*(n)))
 #endif
 
 /*