From bb722855caf83d1295ddc615d375ee4efb549218 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 19 Sep 2019 11:01:48 +0200 Subject: [PATCH] qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlockFallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The open-coded version does not take much more space and additionally we get rid of the hidden goto. This also requires us to remove the 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_driver.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1965bf4abc..9230e35ff2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21362,8 +21362,6 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver, virStorageSourcePtr src, size_t block_idx) { - int ret = -1; - if (virStorageSourceIsEmpty(src)) return 0; @@ -21372,18 +21370,22 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver, return 0; } - if (src->allocation) - QEMU_ADD_BLOCK_PARAM_ULL(params, block_idx, - "allocation", src->allocation); - if (src->capacity) - QEMU_ADD_BLOCK_PARAM_ULL(params, block_idx, - "capacity", src->capacity); - if (src->physical) - QEMU_ADD_BLOCK_PARAM_ULL(params, block_idx, - "physical", src->physical); - ret = 0; - cleanup: - return ret; + if (src->allocation && + virTypedParamListAddULLong(params, src->allocation, + "block.%zu.allocation", block_idx) < 0) + return -1; + + if (src->capacity && + virTypedParamListAddULLong(params, src->capacity, + "block.%zu.capacity", block_idx) < 0) + return -1; + + if (src->physical && + virTypedParamListAddULLong(params, src->physical, + "block.%zu.physical", block_idx) < 0) + return -1; + + return 0; }