Change parameter @total_size and return value to uint64_t.  Callers
mix uint64_t and int64_t.  Thus, the commit reduces, but does not
eliminate implicit conversions.

qcow2_create2() passes a (presumably non-negative) int64_t argument,
then passes the result through a local variable to
qemu_opt_set_number().  Change the local variable to uint64_t to avoid
pointless conversions.

qcow2_measure() passes a uint64_t argument, then assigns the result to
int64_t (which the next commit will change to uint64_t).

Signed-off-by: Markus Armbruster <arm...@redhat.com>
---
 block/qcow2.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index d7c600b..d96d1f6 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2613,13 +2613,13 @@ int64_t qcow2_refcount_metadata_size(int64_t clusters, 
size_t cluster_size,
  * Returns: Total number of bytes required for the fully allocated image
  * (including metadata).
  */
-static int64_t qcow2_calc_prealloc_size(int64_t total_size,
-                                        size_t cluster_size,
-                                        int refcount_order)
+static uint64_t qcow2_calc_prealloc_size(uint64_t total_size,
+                                         size_t cluster_size,
+                                         int refcount_order)
 {
-    int64_t meta_size = 0;
+    uint64_t meta_size = 0;
     uint64_t nl1e, nl2e;
-    int64_t aligned_total_size = align_offset(total_size, cluster_size);
+    uint64_t aligned_total_size = align_offset(total_size, cluster_size);
 
     /* header: 1 cluster */
     meta_size += cluster_size;
@@ -2729,7 +2729,7 @@ static int qcow2_create2(const char *filename, int64_t 
total_size,
     int ret;
 
     if (prealloc == PREALLOC_MODE_FULL || prealloc == PREALLOC_MODE_FALLOC) {
-        int64_t prealloc_size =
+        uint64_t prealloc_size =
             qcow2_calc_prealloc_size(total_size, cluster_size, refcount_order);
         qemu_opt_set_number(opts, BLOCK_OPT_SIZE, prealloc_size, &error_abort);
         qemu_opt_set(opts, BLOCK_OPT_PREALLOC, PreallocMode_lookup[prealloc],
-- 
2.7.5


Reply via email to