aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2016-11-29 14:15:14 +0000
committerStefan Hajnoczi <stefanha@redhat.com>2016-11-29 14:15:14 +0000
commit51cd8ef8ad014675e93dda2ad55537bbb23c9648 (patch)
tree0abeac6185833b8cbcdc86292472fee042b6c3c0
parent38e532aa7430ddf5177ff32bc3bb5f115449b0ec (diff)
parent6725f887acc023fc8850d62e1aaef083fdb4f3d4 (diff)
downloadqemu-51cd8ef8ad014675e93dda2ad55537bbb23c9648.zip
qemu-51cd8ef8ad014675e93dda2ad55537bbb23c9648.tar.gz
qemu-51cd8ef8ad014675e93dda2ad55537bbb23c9648.tar.bz2
Merge remote-tracking branch 'fam/tags/for-upstream' into staging
# gpg: Signature made Tue 29 Nov 2016 10:33:34 AM GMT # gpg: using RSA key 0xCA35624C6A9171C6 # gpg: Good signature from "Fam Zheng <famz@redhat.com>" # Primary key fingerprint: 5003 7CB7 9706 0F76 F021 AD56 CA35 624C 6A91 71C6 * fam/tags/for-upstream: hbitmap: Fix shifts of constants by granularity Message-id: 20161129103438.15955-1-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r--util/hbitmap.c8
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);