From 818afd6eb058b96755a2d1fc1da9def06bfa90c6 Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Wed, 7 Mar 2018 16:35:46 -0800 Subject: [PATCH] qcow: Fix refcount_bytes This should be the number of bits (1 << order) divided by bits per byte. BUG=none TEST=cargo test Change-Id: I201dbaf21d13a82af6bcb493ba5f3b62c89286fa Signed-off-by: Dylan Reid Reviewed-on: https://chromium-review.googlesource.com/954348 Reviewed-by: Stephen Barber Reviewed-by: Zach Reizner --- qcow/src/qcow.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcow/src/qcow.rs b/qcow/src/qcow.rs index df504ded82..0567c6819e 100644 --- a/qcow/src/qcow.rs +++ b/qcow/src/qcow.rs @@ -143,7 +143,7 @@ impl QcowHeader { // Pre-allocate enough clusters for the entire refcount table as it must be // continuous in the file. Allocate enough space to refcount all clusters, including // the refcount clusters. - let refcount_bytes = 0x01u32 << DEFAULT_REFCOUNT_ORDER / 8; + let refcount_bytes = (0x01u32 << DEFAULT_REFCOUNT_ORDER) / 8; let for_data = div_round_up_u32(num_clusters * refcount_bytes, cluster_size); let for_refcounts = div_round_up_u32(for_data * refcount_bytes, cluster_size); let max_refcount_clusters = for_data + for_refcounts;