diff options
-rw-r--r-- | util/hbitmap.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/util/hbitmap.c b/util/hbitmap.c index 5d1a21c..9f691b7 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -399,9 +399,13 @@ bool hbitmap_get(const HBitmap *hb, uint64_t item) uint64_t hbitmap_serialization_granularity(const HBitmap *hb) { + /* Must hold true so that the shift below is defined + * (ld(64) == 6, i.e. 1 << 6 == 64) */ + assert(hb->granularity < 64 - 6); + /* 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 @@ -594,7 +598,7 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size) if (shrink) { /* Don't clear partial granularity groups; * start at the first full one. */ - uint64_t start = QEMU_ALIGN_UP(num_elements, 1 << hb->granularity); + uint64_t start = ROUND_UP(num_elements, UINT64_C(1) << hb->granularity); uint64_t fix_count = (hb->size << hb->granularity) - start; assert(fix_count); |