VIR_AUTOFREE is a beautiful macro. Let's use it across the board
inside qemu_driver.c to make the code a bit tidier and smaller,
sparing VIR_FREE() calls and sometimes a whole 'cleanup'
label.
This is the last part of this change.
Signed-off-by: Daniel Henrique Barboza
---
src/qemu/qemu_driver.c | 119 ++---
1 file changed, 41 insertions(+), 78 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 489698108d..bd05aa9e11 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12055,7 +12055,7 @@ qemuDomainMemoryPeek(virDomainPtr dom,
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
-char *tmp = NULL;
+VIR_AUTOFREE(char *) tmp = NULL;
int fd = -1, ret = -1;
qemuDomainObjPrivatePtr priv;
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
@@ -12127,7 +12127,6 @@ qemuDomainMemoryPeek(virDomainPtr dom,
VIR_FORCE_CLOSE(fd);
if (tmp)
unlink(tmp);
-VIR_FREE(tmp);
virDomainObjEndAPI(&vm);
return ret;
}
@@ -12293,7 +12292,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver,
int ret = -1;
int fd = -1;
struct stat sb;
-char *buf = NULL;
+VIR_AUTOFREE(char *) buf = NULL;
ssize_t len;
if ((rc = qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb,
@@ -12329,7 +12328,6 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver,
ret = 1;
cleanup:
-VIR_FREE(buf);
qemuDomainStorageCloseStat(src, &fd);
return ret;
}
@@ -12550,7 +12548,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
{
virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL;
-char *origname = NULL;
+VIR_AUTOFREE(char *) origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@@ -12585,7 +12583,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
-VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@@ -12607,7 +12604,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
{
virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL;
-char *origname = NULL;
+VIR_AUTOFREE(char *) origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@@ -12652,7 +12649,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
-VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@@ -12853,7 +12849,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
{
virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL;
-char *origname = NULL;
+VIR_AUTOFREE(char *) origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@@ -12888,7 +12884,6 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
-VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@@ -12914,7 +12909,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
int nbdPort = 0;
int nmigrate_disks;
const char **migrate_disks = NULL;
-char *origname = NULL;
+VIR_AUTOFREE(char *) origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@@ -12977,7 +12972,6 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
VIR_FREE(migrate_disks);
-VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@@ -12997,7 +12991,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
{
virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL;
-char *origname = NULL;
+VIR_AUTOFREE(char *) origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@@ -13026,7 +13020,6 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
-VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@@ -13046,7 +13039,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr
dconn,
virDomainDefPtr def = NULL;
const char *dom_xml = NULL;
const char *dname = NULL;
-char *origname = NULL;
+VIR_AUTOFREE(char *) origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@@ -13085,7 +13078,6 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr
dconn,
cleanup:
qemuMigrationParamsFree(migParams);
-VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@@ -13407,7 +13399,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
unsigned domain = 0, bus = 0, slot = 0, function = 0;
int ret = -1;
virNodeDeviceDefPtr def = NULL;
-char *xml = NULL;
+VIR_AUTOFREE(char *) xml = NULL;
bool vfio = qemuHostdevHostSupportsPassthroughVFIO();
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
@@ -13457,7 +13449,6 @