Skip to content

Commit

Permalink
lib: Fix generic strnlen_user for 32-bit big-endian machines
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: David S. Miller <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
paulusmack authored and torvalds committed May 28, 2012
1 parent 1e2aec8 commit 69ea640
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/strnlen_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*
Expand Down

0 comments on commit 69ea640

Please sign in to comment.