From: Wei Wang <wei.w.wang@intel.com>
To: qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com,
quintela@redhat.com
Cc: mst@redhat.com
Subject: [Qemu-devel] [PATCH v2] bitmap: fix BITMAP_LAST_WORD_MASK
Date: Tue, 31 Jul 2018 18:01:18 +0800 [thread overview]
Message-ID: <1533031278-5615-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. 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: Juan Quintela <quintela@redhat.com>
CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
CC: Peter Xu <peterx@redhat.com>
---
include/qemu/bitmap.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
v1->v2 ChangeLog:
- fix the macro directly, instead of fixing the callers one by one.
diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
index 509eedd..9372423 100644
--- a/include/qemu/bitmap.h
+++ b/include/qemu/bitmap.h
@@ -60,7 +60,10 @@
*/
#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 DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]
--
2.7.4
next reply other threads:[~2018-07-31 10:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-31 10:01 Wei Wang [this message]
2018-07-31 14:44 ` [Qemu-devel] [PATCH v2] bitmap: fix BITMAP_LAST_WORD_MASK Juan Quintela
2018-08-07 7:39 ` Peter Xu
2018-08-07 8:21 ` Wei Wang
2018-08-07 9:53 ` Dr. David Alan Gilbert
2018-08-08 1:34 ` Wei Wang
2018-08-08 8:29 ` Dr. David Alan Gilbert
2018-08-07 12:17 ` Peter Xu
2018-08-08 1:30 ` Wei Wang
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=1533031278-5615-1-git-send-email-wei.w.wang@intel.com \
--to=wei.w.wang@intel.com \
--cc=dgilbert@redhat.com \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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).