Skip to contentSkip to conversation

hbitmap: Fix the serialization granularity's type

PATCH In review Max Reitz 2 participants 2 messages Nov 7, 2016 – Nov 8, 2016

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 hbitmap: Fix the serialization granularity's type

This function returns a uint64_t, so it should not truncate its result by performing a plain int calculation.

---
 util/hbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/hbitmap.c +1 -1
index 5d1a21c..c57be76 100644
@@ -401,7 +401,7 @@ uint64_t hbitmap_serialization_granularity(const HBitmap *hb)
 {
     /* Require at least 64 bit granularity to be safe on both 64 bit and 32 bit
      * hosts. */
-    return 64 << hb->granularity;
+    return UINT64_C(64) << hb->granularity;
 }
 
 /* Start should be aligned to serialization granularity, chunk size should be
Signature · 1 line
2.10.2
#1 lore raw
Quoted 13 lines · Max Reitz

This function returns a uint64_t, so it should not truncate its result by performing a plain int calculation.

---
 util/hbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/hbitmap.c +0 -0
index 5d1a21c..c57be76 100644

util/hbitmap.c uint64_t hbitmap_serialization_granularity(const HBitmap *hb) · line 405

Quoted 6 lines
util/hbitmap.c +1 -1
@@ -401,7 +401,7 @@ uint64_t hbitmap_serialization_granularity(const HBitmap *hb)
 {
     /* Require at least 64 bit granularity to be safe on both 64 bit and 32 bit
      * hosts. */
-    return 64 << hb->granularity;
+    return UINT64_C(64) << hb->granularity;
 }

Another instance that should be fixed:

  uint64_t start = QEMU_ALIGN_UP(num_elements, 1 << hb->granularity);