From: Kirill Shchetiniuk <[email protected]>

Use auto memory management, no more cleanup stage required

Signed-off-by: Kirill Shchetiniuk <[email protected]>
---
 src/qemu/qemu_driver.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 12a1b2ae9d..6ee54f95a4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4140,19 +4140,19 @@ static int
 qemuDomainSetVcpusAgent(virDomainObj *vm,
                         unsigned int nvcpus)
 {
-    qemuAgentCPUInfo *cpuinfo = NULL;
+    g_autofree qemuAgentCPUInfo *cpuinfo = NULL;
     qemuAgent *agent;
     int ncpuinfo;
     int ret = -1;
 
     if (!qemuDomainAgentAvailable(vm, true))
-        goto cleanup;
+        return -1;
 
     if (nvcpus > virDomainDefGetVcpus(vm->def)) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("requested vcpu count is greater than the count of 
enabled vcpus in the domain: %1$d > %2$d"),
                        nvcpus, virDomainDefGetVcpus(vm->def));
-        goto cleanup;
+        return -1;
     }
 
     agent = qemuDomainObjEnterAgent(vm);
@@ -4161,21 +4161,18 @@ qemuDomainSetVcpusAgent(virDomainObj *vm,
     agent = NULL;
 
     if (ncpuinfo < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuAgentUpdateCPUInfo(nvcpus, cpuinfo, ncpuinfo) < 0)
-        goto cleanup;
+        return -1;
 
     if (!qemuDomainAgentAvailable(vm, true))
-        goto cleanup;
+        return -1;
 
     agent = qemuDomainObjEnterAgent(vm);
     ret = qemuAgentSetVCPUs(agent, cpuinfo, ncpuinfo);
     qemuDomainObjExitAgent(vm, agent);
 
- cleanup:
-    VIR_FREE(cpuinfo);
-
     return ret;
 }
 
-- 
2.49.0

Reply via email to