fbe740
From 45226d208c57719b50152dbec99a75969989208b Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <45226d208c57719b50152dbec99a75969989208b@dist-git>
fbe740
From: Jiri Denemark <jdenemar@redhat.com>
fbe740
Date: Tue, 26 May 2020 10:59:12 +0200
fbe740
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86DataParse
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
(cherry picked from commit c1532711dda6db27c7f6fa7d86ab5ec5d2ab2224)
fbe740
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
fbe740
fbe740
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
fbe740
Message-Id: <e98c6869043aa0b7d0cc3adffe879f5d7d3c39f2.1590483392.git.jdenemar@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/cpu/cpu_x86.c | 23 ++++++++---------------
fbe740
 1 file changed, 8 insertions(+), 15 deletions(-)
fbe740
fbe740
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
fbe740
index cb5a2f941e..107fd9227d 100644
fbe740
--- a/src/cpu/cpu_x86.c
fbe740
+++ b/src/cpu/cpu_x86.c
fbe740
@@ -1636,8 +1636,8 @@ virCPUx86DataFormat(const virCPUData *data)
fbe740
 static virCPUDataPtr
fbe740
 virCPUx86DataParse(xmlXPathContextPtr ctxt)
fbe740
 {
fbe740
-    xmlNodePtr *nodes = NULL;
fbe740
-    virCPUDataPtr cpuData = NULL;
fbe740
+    g_autofree xmlNodePtr *nodes = NULL;
fbe740
+    g_autoptr(virCPUData) cpuData = NULL;
fbe740
     virCPUx86DataItem item;
fbe740
     size_t i;
fbe740
     int n;
fbe740
@@ -1646,11 +1646,11 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
fbe740
     if (n <= 0) {
fbe740
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
fbe740
                        _("no x86 CPU data found"));
fbe740
-        goto error;
fbe740
+        return NULL;
fbe740
     }
fbe740
 
fbe740
     if (!(cpuData = virCPUDataNew(VIR_ARCH_X86_64)))
fbe740
-        goto error;
fbe740
+        return NULL;
fbe740
 
fbe740
     for (i = 0; i < n; i++) {
fbe740
         ctxt->node = nodes[i];
fbe740
@@ -1658,28 +1658,21 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
fbe740
             if (x86ParseCPUID(ctxt, &item) < 0) {
fbe740
                 virReportError(VIR_ERR_INTERNAL_ERROR,
fbe740
                                _("failed to parse cpuid[%zu]"), i);
fbe740
-                goto error;
fbe740
+                return NULL;
fbe740
             }
fbe740
         } else {
fbe740
             if (x86ParseMSR(ctxt, &item) < 0) {
fbe740
                 virReportError(VIR_ERR_INTERNAL_ERROR,
fbe740
                                _("failed to parse msr[%zu]"), i);
fbe740
-                goto error;
fbe740
+                return NULL;
fbe740
             }
fbe740
         }
fbe740
 
fbe740
         if (virCPUx86DataAdd(cpuData, &item) < 0)
fbe740
-            goto error;
fbe740
+            return NULL;
fbe740
     }
fbe740
 
fbe740
- cleanup:
fbe740
-    VIR_FREE(nodes);
fbe740
-    return cpuData;
fbe740
-
fbe740
- error:
fbe740
-    virCPUx86DataFree(cpuData);
fbe740
-    cpuData = NULL;
fbe740
-    goto cleanup;
fbe740
+    return g_steal_pointer(&cpuData);
fbe740
 }
fbe740
 
fbe740
 
fbe740
-- 
fbe740
2.26.2
fbe740