Signed-off-by: Frediano Ziglio <fredd...@gmail.com> --- block/qcow2-refcount.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 0e31868..318d66d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -681,14 +681,13 @@ void qcow2_create_refcount_update(QCowCreateState *s, int64_t offset, int64_t size) { int refcount; - int64_t start, last, cluster_offset; + int64_t start, last, cluster; uint16_t *p; - start = offset & ~(s->cluster_size - 1); - last = (offset + size - 1) & ~(s->cluster_size - 1); - for(cluster_offset = start; cluster_offset <= last; - cluster_offset += s->cluster_size) { - p = &s->refcount_block[cluster_offset >> s->cluster_bits]; + start = offset >> s->cluster_bits; + last = (offset + size - 1) >> s->cluster_bits; + for (cluster = start; cluster <= last; ++cluster) { + p = &s->refcount_block[cluster]; refcount = be16_to_cpu(*p); refcount++; *p = cpu_to_be16(refcount); -- 1.7.1