From ae0c36ecbb7a9785f25d8851c59de2b3332c9a24 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 4 Apr 2019 11:03:24 +0200 Subject: [PATCH] qemu: block: Use VIR_AUTOPTR for virHashTablePtr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_block.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 0504a79957..b00f4c6f8e 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -240,8 +240,8 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namednodes, virJSONValuePtr blockstats) { struct qemuBlockNodeNameGetBackingChainData data; - virHashTablePtr namednodestable = NULL; - virHashTablePtr disks = NULL; + VIR_AUTOPTR(virHashTable) namednodestable = NULL; + VIR_AUTOPTR(virHashTable) disks = NULL; virHashTablePtr ret = NULL; memset(&data, 0, sizeof(data)); @@ -268,8 +268,6 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namednodes, VIR_STEAL_PTR(ret, disks); cleanup: - virHashFree(namednodestable); - virHashFree(disks); return ret; } @@ -344,7 +342,7 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver, qemuDomainAsyncJob asyncJob) { qemuDomainObjPrivatePtr priv = vm->privateData; - virHashTablePtr disktable = NULL; + VIR_AUTOPTR(virHashTable) disktable = NULL; VIR_AUTOPTR(virJSONValue) data = NULL; VIR_AUTOPTR(virJSONValue) blockstats = NULL; virDomainDiskDefPtr disk; @@ -376,7 +374,6 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver, ret = 0; cleanup: - virHashFree(disktable); return ret; } @@ -394,19 +391,20 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver, virHashTablePtr qemuBlockGetNodeData(virJSONValuePtr data) { + VIR_AUTOPTR(virHashTable) nodedata = NULL; virHashTablePtr ret = NULL; - if (!(ret = virHashCreate(50, virJSONValueHashFree))) + if (!(nodedata = virHashCreate(50, virJSONValueHashFree))) return NULL; if (virJSONValueArrayForeachSteal(data, - qemuBlockNamedNodesArrayToHash, ret) < 0) + qemuBlockNamedNodesArrayToHash, nodedata) < 0) goto error; + VIR_STEAL_PTR(ret, nodedata); return ret; error: - virHashFree(ret); return NULL; }