Commit 51cd8ef8 authored by Stefan Hajnoczi's avatar Stefan Hajnoczi
Browse files

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: default avatarStefan Hajnoczi <stefanha@redhat.com>
parents 38e532aa 6725f887
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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);