[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 25/56] block/qcow2: Change qcow2_calc_prealloc_s
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [RFC PATCH 25/56] block/qcow2: Change qcow2_calc_prealloc_size() to uint64_t |
Date: |
Mon, 7 Aug 2017 16:45:29 +0200 |
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 <address@hidden>
---
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
- Re: [Qemu-devel] [RFC PATCH 01/56] qobject: Touch up comments to say @param instead of 'param', (continued)
- [Qemu-devel] [RFC PATCH 17/56] migration: Make MigrationStats sizes unsigned in QAPI/QMP, Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 19/56] block: Make snapshot VM state size unsigned in QAPI/QMP, Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 13/56] pci: Make PCI addresses and sizes unsigned in QAPI/QMP, Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 16/56] migration: Make XBZRLE transferred size unsigned in QAPI/QMP, Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 21/56] block: Clean up get_human_readable_size(), Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 22/56] block: Mix up signed and unsigned less in bdrv_img_create(), Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 25/56] block/qcow2: Change qcow2_calc_prealloc_size() to uint64_t,
Markus Armbruster <=
- [Qemu-devel] [RFC PATCH 24/56] block/qcow2: Change align_offset() to operate on uint64_t, Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 18/56] migration: Make parameter max-bandwidth unsigned in QAPI/QMP, Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 02/56] qdict: New helpers to put and get unsigned integers, Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 06/56] char: Don't truncate -chardev and HMP chardev-add ringbuf size, Markus Armbruster, 2017/08/07
- [Qemu-devel] [RFC PATCH 15/56] migration: Make XBZRLE cache size unsigned in QAPI/QMP, Markus Armbruster, 2017/08/07