On 11/26/2012 01:36 PM, Guannan Ren wrote:
This bug leads to get incorrect vcpupin information via
qemudDomainGetVcpuPinInfo() API when the number of maximum
cpu on a host falls into a range such as 31 < ncpus < 64.
gcc warning:
left shift count >= width of type
The following bug is such the case
https://bugzilla.redhat.com/show_bug.cgi?id=876415
---
src/util/bitmap.c | 4 ++--
tests/virbitmaptest.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/src/util/bitmap.c b/src/util/bitmap.c
index 5ec5440..c29f5f3 100644
--- a/src/util/bitmap.c
+++ b/src/util/bitmap.c
@@ -574,8 +574,8 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap)
return false;
if (unusedBits > 0) {
- if ((bitmap->map[sz] & ((1U << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
- != ((1U << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
+ if ((bitmap->map[sz] & ((1UL << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
+ != ((1UL << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
return false;
}
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index f1eb9d5..e21bb02 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -347,6 +347,37 @@ error:
return ret;
}
+static int test7(const void *v ATTRIBUTE_UNUSED)
+{
+ virBitmapPtr bitmap;
+ size_t i;
+ size_t maxBit[] = {
+ 1, 8, 31, 32, 63, 64, 95, 96, 127, 128, 159, 160
+ };
+ size_t nmaxBit = 12;
+
+ for (i = 0; i < nmaxBit; i++) {
+ bitmap = virBitmapNew(maxBit[i]);
+ if (!bitmap)
+ goto error;
+
+ if (virBitmapIsAllSet(bitmap))
+ goto error;
+
+ virBitmapSetAll(bitmap);
+ if (!virBitmapIsAllSet(bitmap))
+ goto error;
+
+ virBitmapFree(bitmap);
+ }
+
+ return 0;
+
+error:
+ virBitmapFree(bitmap);
+ return -1;
+}
+
static int
mymain(void)
{
@@ -364,6 +395,8 @@ mymain(void)
ret = -1;
if (virtTestRun("test6", 1, test6, NULL) < 0)
ret = -1;
+ if (virtTestRun("test7", 1, test7, NULL) < 0)
+ ret = -1;
return ret;
ping?
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list