mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
tests: use g_auto in cpuTestMakeQEMUCaps
Refactor to use automatic cleanup and remove the goto's. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
55031c09e6
commit
e2b5fc9a8b
@ -463,18 +463,18 @@ typedef enum {
|
||||
static virQEMUCaps *
|
||||
cpuTestMakeQEMUCaps(const struct data *data)
|
||||
{
|
||||
virQEMUCaps *qemuCaps = NULL;
|
||||
qemuMonitorTest *testMon = NULL;
|
||||
qemuMonitorCPUModelInfo *model = NULL;
|
||||
virCPUDef *cpu = NULL;
|
||||
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
||||
g_autoptr(qemuMonitorTest) testMon = NULL;
|
||||
g_autoptr(qemuMonitorCPUModelInfo) model = NULL;
|
||||
g_autoptr(virCPUDef) cpu = NULL;
|
||||
bool fail_no_props = true;
|
||||
char *json = NULL;
|
||||
g_autofree char *json = NULL;
|
||||
|
||||
json = g_strdup_printf("%s/cputestdata/%s-cpuid-%s.json", abs_srcdir,
|
||||
virArchToString(data->arch), data->host);
|
||||
|
||||
if (!(testMon = qemuMonitorTestNewFromFile(json, driver.xmlopt, true)))
|
||||
goto error;
|
||||
return NULL;
|
||||
|
||||
qemuMonitorTestAllowUnusedCommands(testMon);
|
||||
|
||||
@ -488,10 +488,10 @@ cpuTestMakeQEMUCaps(const struct data *data)
|
||||
if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon),
|
||||
QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
|
||||
cpu, true, fail_no_props, &model) < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
|
||||
if (!(qemuCaps = virQEMUCapsNew()))
|
||||
goto error;
|
||||
return NULL;
|
||||
|
||||
virQEMUCapsSet(qemuCaps, QEMU_CAPS_KVM);
|
||||
if (data->flags == JSON_MODELS ||
|
||||
@ -504,20 +504,9 @@ cpuTestMakeQEMUCaps(const struct data *data)
|
||||
|
||||
if (virQEMUCapsProbeCPUDefinitionsTest(qemuCaps,
|
||||
qemuMonitorTestGetMonitor(testMon)) < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorCPUModelInfoFree(model);
|
||||
qemuMonitorTestFree(testMon);
|
||||
virCPUDefFree(cpu);
|
||||
VIR_FREE(json);
|
||||
|
||||
return qemuCaps;
|
||||
|
||||
error:
|
||||
virObjectUnref(qemuCaps);
|
||||
qemuCaps = NULL;
|
||||
goto cleanup;
|
||||
return g_steal_pointer(&qemuCaps);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user