On a Thursday in 2021, Daniel Henrique Barboza wrote:
All 'virCPUDef' pointers can be auto-freed and the
'cleanup' label
removed.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
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;
migCPU is also freed manually if virQEMUCapsInitCPUModel fails.
However in both callers of virQEMUCapsInitCPUModel the cpu argument is
allocated right above by virQEMUCapsNewHostCPUModel().
By moving the allocation inside virQEMUCapsInitCPUModel, the
virCPUDefFree can be removed.
Jano
+ g_autoptr(virCPUDef) hostCPU = NULL;
+ g_autoptr(virCPUDef) fullCPU = NULL;
size_t i;
int rc;