Message ID | 1532934837-5966-3-git-send-email-wei.w.wang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | bitmap: some fixes | expand |
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); }
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(-)