From 661533fb67735cfede069865c417b28a9812b7b9 Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Fri, 17 Jul 2020 18:15:54 -0300 Subject: [PATCH] qemu_driver.c: modernize qemuConnectCPUModelBaseline() Use g_autoptr() on pointers and remove the unneeded 'cleanup' label. Signed-off-by: Daniel Henrique Barboza Message-Id: <20200717211556.1024748-4-danielhb413@gmail.com> Reviewed-by: Jiri Denemark --- 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 e3927cd431..b1fe55b757 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13343,50 +13343,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); }