linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK
@ 2018-07-26  8:07 Wei Wang
  2018-07-26  8:48 ` Andy Shevchenko
  2018-07-26  9:37 ` Yury Norov
  0 siblings, 2 replies; 14+ messages in thread
From: Wei Wang @ 2018-07-26  8:07 UTC (permalink / raw)
  To: linux-kernel, akpm, ynorov, corbet, linux; +Cc: dgilbert, mawilcox, wei.w.wang

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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-08-14 12:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26  8:07 [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK Wei Wang
2018-07-26  8:48 ` 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

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).