From: Wei Wang <wei.w.wang@intel.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
ynorov@caviumnetworks.com, corbet@lwn.net,
linux@rasmusvillemoes.dk
Cc: dgilbert@redhat.com, mawilcox@microsoft.com, wei.w.wang@intel.com
Subject: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK
Date: Thu, 26 Jul 2018 16:07:51 +0800 [thread overview]
Message-ID: <1532592471-21177-1-git-send-email-wei.w.wang@intel.com> (raw)
The existing BITMAP_LAST_WORD_MASK macro returns 0xffffffff if nbits is
0. This patch changes the macro to return 0 when there is no bit needs to
be masked.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Yury Norov <ynorov@caviumnetworks.com>
---
include/linux/bitmap.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 1ee46f4..12af3d7 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -194,7 +194,10 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf,
const unsigned long *maskp, int nmaskbits);
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
-#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
+#define BITMAP_LAST_WORD_MASK(nbits) \
+( \
+ nbits ? (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) : 0 \
+)
#define small_const_nbits(nbits) \
(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
--
2.7.4
next reply other threads:[~2018-07-26 8:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-26 8:07 Wei Wang [this message]
2018-07-26 8:48 ` [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK Andy Shevchenko
2018-07-26 10:08 ` Wei Wang
2018-07-26 14:00 ` Andy Shevchenko
2018-07-26 9:37 ` Yury Norov
2018-07-26 10:15 ` Wei Wang
2018-07-26 12:10 ` Yury Norov
2018-07-27 2:13 ` Wei Wang
2018-08-06 23:30 ` Rasmus Villemoes
2018-08-07 7:03 ` Wei Wang
2018-08-07 7:15 ` Wei Wang
2018-08-07 10:26 ` Andy Shevchenko
2018-08-07 11:22 ` Wei Wang
2018-08-14 12:46 ` Andy Shevchenko
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=1532592471-21177-1-git-send-email-wei.w.wang@intel.com \
--to=wei.w.wang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dgilbert@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mawilcox@microsoft.com \
--cc=ynorov@caviumnetworks.com \
/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).