From: Wei Wang <wei.w.wang@intel.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
andy.shevchenko@gmail.com, ynorov@caviumnetworks.com,
corbet@lwn.net, linux@rasmusvillemoes.dk
Cc: dgilbert@redhat.com, wei.w.wang@intel.com
Subject: [PATCH v2] linux/bitmap.h: comments on BITMAP_LAST_WORD_MASK
Date: Fri, 27 Jul 2018 16:03:31 +0800 [thread overview]
Message-ID: <1532678611-9136-1-git-send-email-wei.w.wang@intel.com> (raw)
When "nbits = 0" which means no bits to mask, this macro is expected to
return 0, instead of 0xffffffff. Currently, the "nbits = 0" case is
avoided by the callers themselves (e.g.__bitmap_intersects,
__bitmap_weight). This corner case should be explicitly noted.
This patch simply adds a comment above the macro as a note to users about
the corner case.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Yury Norov <ynorov@caviumnetworks.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
include/linux/bitmap.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 1ee46f4..4e64d1f 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -194,6 +194,7 @@ 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)))
+/* "nbits = 0" is not applicable to this macro. Callers should avoid that. */
#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
#define small_const_nbits(nbits) \
--
2.7.4
reply other threads:[~2018-07-27 8:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1532678611-9136-1-git-send-email-wei.w.wang@intel.com \
--to=wei.w.wang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andy.shevchenko@gmail.com \
--cc=corbet@lwn.net \
--cc=dgilbert@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--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).