-----BEGIN PGP SIGNATURE-----

Version: GnuPG v2
 
 iQEtBAABCAAXBQJYPVl+EBxmYW16QHJlZGhhdC5jb20ACgkQyjViTGqRccb2Rwf/
 dAPteR0fuG0Adep5khJgqNqJqNo78UAYE34Nj7e9WborLcaNV8qU38sgUHy8BGFL
 ccrRSOKr2BRKvKITb4PxBbysch9YyyqSjVCUOuxqpUD9eMkUeyU+3HU/5xzHb3nt
 jsGlK/bvABx72vrBcNt3qDe7MLoLlFQvGCE4+YgjjdMdrw9j+c1KWLgfadLRX263
 DItvnivi0ZuGmY4+5G2ULLUc4IIk6L0pKFD5mdKfNzVoai3Hx/rmfz93MlXEYKgf
 qWcDrb6u2bfvwgPgN0My5aXTbBk1f+iHAOU5pe9SrFG57mMi+Lu/f/mUGun9irEH
 LLa8D40XlroCGNQcW/S3vw==
 =Ql7f
 -----END PGP SIGNATURE-----

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>
This commit is contained in:
Stefan Hajnoczi 2016-11-29 14:15:14 +00:00
commit 51cd8ef8ad
1 changed files with 6 additions and 2 deletions

View File

@ -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);