Use g_autoptr() on pointers and remove the unneeded 'cleanup' label.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_driver.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d185666ed8..d73d093465 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13342,50 +13342,44 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps,
virCPUDefPtr *cpus,
int ncpus)
{
- qemuProcessQMPPtr proc;
- virCPUDefPtr ret = NULL;
- virCPUDefPtr baseline = NULL;
+ g_autoptr(qemuProcessQMP) proc = NULL;
+ g_autoptr(virCPUDef) baseline = NULL;
qemuMonitorCPUModelInfoPtr result = NULL;
size_t i;
if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps),
libDir, runUid, runGid, false)))
- goto cleanup;
+ return NULL;
if (qemuProcessQMPStart(proc) < 0)
- goto cleanup;
+ return NULL;
if (VIR_ALLOC(baseline) < 0)
- goto cleanup;
+ return NULL;
if (virCPUDefCopyModel(baseline, cpus[0], false))
- goto cleanup;
+ return NULL;
for (i = 1; i < ncpus; i++) {
if (qemuMonitorGetCPUModelBaseline(proc->mon, baseline,
cpus[i], &result) < 0)
- goto cleanup;
+ return NULL;
if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
- goto cleanup;
+ return NULL;
}
if (expand_features) {
if (qemuMonitorGetCPUModelExpansion(proc->mon,
QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
baseline, true, false, &result) < 0)
- goto cleanup;
+ return NULL;
if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
- goto cleanup;
+ return NULL;
}
- ret = g_steal_pointer(&baseline);
-
- cleanup:
- qemuProcessQMPFree(proc);
- virCPUDefFree(baseline);
- return ret;
+ return g_steal_pointer(&baseline);
}
--
2.26.2