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 <danielhb413@gmail.com> Message-Id: <20200717211556.1024748-5-danielhb413@gmail.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
661533fb67
commit
494f72f786
@ -13148,19 +13148,19 @@ qemuConnectCPUModelComparison(virQEMUCapsPtr qemuCaps,
|
|||||||
virCPUDefPtr cpu_b,
|
virCPUDefPtr cpu_b,
|
||||||
bool failIncompatible)
|
bool failIncompatible)
|
||||||
{
|
{
|
||||||
qemuProcessQMPPtr proc = NULL;
|
g_autoptr(qemuProcessQMP) proc = NULL;
|
||||||
char *result = NULL;
|
g_autofree char *result = NULL;
|
||||||
int ret = VIR_CPU_COMPARE_ERROR;
|
int ret = VIR_CPU_COMPARE_ERROR;
|
||||||
|
|
||||||
if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps),
|
if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps),
|
||||||
libDir, runUid, runGid, false)))
|
libDir, runUid, runGid, false)))
|
||||||
goto cleanup;
|
return VIR_CPU_COMPARE_ERROR;
|
||||||
|
|
||||||
if (qemuProcessQMPStart(proc) < 0)
|
if (qemuProcessQMPStart(proc) < 0)
|
||||||
goto cleanup;
|
return VIR_CPU_COMPARE_ERROR;
|
||||||
|
|
||||||
if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a, cpu_b, &result) < 0)
|
if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a, cpu_b, &result) < 0)
|
||||||
goto cleanup;
|
return VIR_CPU_COMPARE_ERROR;
|
||||||
|
|
||||||
if (STREQ(result, "identical"))
|
if (STREQ(result, "identical"))
|
||||||
ret = VIR_CPU_COMPARE_IDENTICAL;
|
ret = VIR_CPU_COMPARE_IDENTICAL;
|
||||||
@ -13171,9 +13171,6 @@ qemuConnectCPUModelComparison(virQEMUCapsPtr qemuCaps,
|
|||||||
else
|
else
|
||||||
ret = VIR_CPU_COMPARE_INCOMPATIBLE;
|
ret = VIR_CPU_COMPARE_INCOMPATIBLE;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(result);
|
|
||||||
qemuProcessQMPFree(proc);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user