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 2/2] bitmap: fix bitmap_count_one
Date: Mon, 30 Jul 2018 15:13:57 +0800 [thread overview]
Message-ID: <1532934837-5966-3-git-send-email-wei.w.wang@intel.com> (raw)
In-Reply-To: <1532934837-5966-1-git-send-email-wei.w.wang@intel.com>
Since "nbits = 0" is not applicable to the BITMAP_LAST_WORD_MASK macro,
callers need to avoid passing "nbits = 0" to this macro, which generates
incorrect results.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
CC: Juan Quintela <quintela@redhat.com>
CC: Peter Xu <peterx@redhat.com>
---
include/qemu/bitmap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
index f53c640..e45e9c0 100644
--- a/include/qemu/bitmap.h
+++ b/include/qemu/bitmap.h
@@ -223,7 +223,7 @@ static inline int bitmap_intersects(const unsigned long *src1,
static inline long bitmap_count_one(const unsigned long *bitmap, long nbits)
{
if (small_nbits(nbits)) {
- return ctpopl(*bitmap & BITMAP_LAST_WORD_MASK(nbits));
+ return nbits ? ctpopl(*bitmap & BITMAP_LAST_WORD_MASK(nbits)) : 0;
} else {
return slow_bitmap_count_one(bitmap, nbits);
}
--
2.7.4
prev parent reply other threads:[~2018-07-30 7:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 7:13 [Qemu-devel] [PATCH 0/2] bitmap: some fixes Wei Wang
2018-07-30 7:13 ` [Qemu-devel] [PATCH 1/2] bitmap.h: add comments to BITMAP_LAST_WORD_MASK Wei Wang
2018-07-30 8:02 ` Wei Wang
2018-07-30 13:19 ` Juan Quintela
2018-07-31 9:06 ` Wei Wang
2018-07-30 7:13 ` Wei Wang [this message]
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=1532934837-5966-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.