Re: [PATCH 7/7] qemu_capabilities.c: use g_autoptr() in virQEMUCapsInitHostCPUModel()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@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;

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;

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux