From: Paul Mackerras <paulus@samba.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linuxppc-dev@ozlabs.org, David Miller <davem@davemloft.net>
Subject: [PATCH 1/2] lib: Fix generic strnlen_user for 32-bit big-endian machines
Date: Mon, 28 May 2012 12:59:56 +1000 [thread overview]
Message-ID: <20120528025956.GA6822@bloggs.ozlabs.ibm.com> (raw)
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>
---
lib/strnlen_user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
index 90900ec..a28df52 100644
--- a/lib/strnlen_user.c
+++ b/lib/strnlen_user.c
@@ -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
/*
--
1.7.10.rc3.219.g53414
next reply other threads:[~2012-05-28 2:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-28 2:59 Paul Mackerras [this message]
2012-05-28 3:03 ` [PATCH 2/2] powerpc: Use the new generic strncpy_from_user() and strnlen_user() Paul Mackerras
2012-05-28 3:56 ` David Miller
2012-05-28 3:55 ` [PATCH 1/2] lib: Fix generic strnlen_user for 32-bit big-endian machines David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120528025956.GA6822@bloggs.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=davem@davemloft.net \
--cc=linuxppc-dev@ozlabs.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).