All 'virCPUDef' pointers can be auto-freed and the 'cleanup' label removed. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/qemu/qemu_capabilities.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5257fe64b2..dbf08d681b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3597,11 +3597,11 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, virArch hostArch, virDomainVirtType type) { - virCPUDef *cpu = NULL; - virCPUDef *cpuExpanded = NULL; - virCPUDef *migCPU = NULL; - virCPUDef *hostCPU = NULL; - virCPUDef *fullCPU = NULL; + g_autoptr(virCPUDef) cpu = NULL; + g_autoptr(virCPUDef) cpuExpanded = NULL; + g_autoptr(virCPUDef) migCPU = NULL; + g_autoptr(virCPUDef) hostCPU = NULL; + g_autoptr(virCPUDef) fullCPU = NULL; size_t i; int rc; @@ -3676,19 +3676,14 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, goto error; } - virQEMUCapsSetHostModel(qemuCaps, type, cpu, migCPU, fullCPU); + virQEMUCapsSetHostModel(qemuCaps, type, g_steal_pointer(&cpu), + g_steal_pointer(&migCPU), + g_steal_pointer(&fullCPU)); - cleanup: - virCPUDefFree(cpuExpanded); - virCPUDefFree(hostCPU); return; error: - virCPUDefFree(cpu); - virCPUDefFree(migCPU); - virCPUDefFree(fullCPU); virResetLastError(); - goto cleanup; } -- 2.31.1