From 82b3f470c66be12a708df3b824417fb8cae07e55 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 15 May 2019 13:41:09 +0200 Subject: [PATCH] qemu: Modernize memory cleaning in qemuDomainBlockPullCommon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use VIR_AUTOFREE and VIR_AUTOUNREF. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_driver.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c9e919023a..c8fb06e934 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17136,13 +17136,13 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, unsigned int flags) { qemuDomainObjPrivatePtr priv = vm->privateData; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - char *device = NULL; + VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); + VIR_AUTOFREE(char *) device = NULL; virDomainDiskDefPtr disk; virStorageSourcePtr baseSource = NULL; unsigned int baseIndex = 0; - char *basePath = NULL; - char *backingPath = NULL; + VIR_AUTOFREE(char *) basePath = NULL; + VIR_AUTOFREE(char *) backingPath = NULL; unsigned long long speed = bandwidth; qemuBlockJobDataPtr job = NULL; int ret = -1; @@ -17235,10 +17235,6 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, cleanup: qemuBlockJobStartupFinalize(job); - virObjectUnref(cfg); - VIR_FREE(basePath); - VIR_FREE(backingPath); - VIR_FREE(device); virDomainObjEndAPI(&vm); return ret; }