From: Daniel Henrique Barboza Date: Fri, 17 Jul 2020 21:15:55 +0000 (-0300) Subject: qemu_driver.c: modernize qemuConnectCPUModelComparison() X-Git-Tag: v6.6.0-rc1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=494f72f786b094b85465fcca212b78ffc16765ff;p=thirdparty%2Flibvirt.git qemu_driver.c: modernize qemuConnectCPUModelComparison() Use g_auto* on pointers to avoid using the 'cleanup' label. In theory the 'ret' variable can also be discarded if the flow of the logic is reworked. Perhaps another time. Signed-off-by: Daniel Henrique Barboza Message-Id: <20200717211556.1024748-5-danielhb413@gmail.com> Reviewed-by: Jiri Denemark --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b1fe55b757..b8ba2e3fb9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13148,19 +13148,19 @@ qemuConnectCPUModelComparison(virQEMUCapsPtr qemuCaps, virCPUDefPtr cpu_b, bool failIncompatible) { - qemuProcessQMPPtr proc = NULL; - char *result = NULL; + g_autoptr(qemuProcessQMP) proc = NULL; + g_autofree char *result = NULL; int ret = VIR_CPU_COMPARE_ERROR; if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps), libDir, runUid, runGid, false))) - goto cleanup; + return VIR_CPU_COMPARE_ERROR; if (qemuProcessQMPStart(proc) < 0) - goto cleanup; + return VIR_CPU_COMPARE_ERROR; if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a, cpu_b, &result) < 0) - goto cleanup; + return VIR_CPU_COMPARE_ERROR; if (STREQ(result, "identical")) ret = VIR_CPU_COMPARE_IDENTICAL; @@ -13171,9 +13171,6 @@ qemuConnectCPUModelComparison(virQEMUCapsPtr qemuCaps, else ret = VIR_CPU_COMPARE_INCOMPATIBLE; - cleanup: - VIR_FREE(result); - qemuProcessQMPFree(proc); return ret; }