fbe740
From 6a7bb46df53af5c1213e3a53a530c8745eb1aa0e Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <6a7bb46df53af5c1213e3a53a530c8745eb1aa0e@dist-git>
fbe740
From: Jiri Denemark <jdenemar@redhat.com>
fbe740
Date: Tue, 26 May 2020 10:59:07 +0200
fbe740
Subject: [PATCH] cpu_x86: Use g_auto* in x86VendorParse
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 6a0a7db9041cb1d8d92919bb4adf0d19bdd5dd68)
fbe740
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
fbe740
fbe740
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
fbe740
Message-Id: <3d21717ab7a594e301afc7f33ddbb32b57a8c56e.1590483392.git.jdenemar@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/cpu/cpu_x86.c | 20 +++++++-------------
fbe740
 1 file changed, 7 insertions(+), 13 deletions(-)
fbe740
fbe740
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
fbe740
index 310dfcbcb3..3ffddf0342 100644
fbe740
--- a/src/cpu/cpu_x86.c
fbe740
+++ b/src/cpu/cpu_x86.c
fbe740
@@ -849,9 +849,8 @@ x86VendorParse(xmlXPathContextPtr ctxt,
fbe740
                void *data)
fbe740
 {
fbe740
     virCPUx86MapPtr map = data;
fbe740
-    virCPUx86VendorPtr vendor = NULL;
fbe740
-    char *string = NULL;
fbe740
-    int ret = -1;
fbe740
+    g_autoptr(virCPUx86Vendor) vendor = NULL;
fbe740
+    g_autofree char *string = NULL;
fbe740
 
fbe740
     vendor = g_new0(virCPUx86Vendor, 1);
fbe740
     vendor->name = g_strdup(name);
fbe740
@@ -859,7 +858,7 @@ x86VendorParse(xmlXPathContextPtr ctxt,
fbe740
     if (x86VendorFind(map, vendor->name)) {
fbe740
         virReportError(VIR_ERR_INTERNAL_ERROR,
fbe740
                        _("CPU vendor %s already defined"), vendor->name);
fbe740
-        goto cleanup;
fbe740
+        return -1;
fbe740
     }
fbe740
 
fbe740
     string = virXPathString("string(@string)", ctxt);
fbe740
@@ -867,21 +866,16 @@ x86VendorParse(xmlXPathContextPtr ctxt,
fbe740
         virReportError(VIR_ERR_INTERNAL_ERROR,
fbe740
                        _("Missing vendor string for CPU vendor %s"),
fbe740
                        vendor->name);
fbe740
-        goto cleanup;
fbe740
+        return -1;
fbe740
     }
fbe740
 
fbe740
     if (virCPUx86VendorToData(string, &vendor->data) < 0)
fbe740
-        goto cleanup;
fbe740
+        return -1;
fbe740
 
fbe740
     if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
fbe740
-        goto cleanup;
fbe740
-
fbe740
-    ret = 0;
fbe740
+        return -1;
fbe740
 
fbe740
- cleanup:
fbe740
-    x86VendorFree(vendor);
fbe740
-    VIR_FREE(string);
fbe740
-    return ret;
fbe740
+    return 0;
fbe740
 }
fbe740
 
fbe740
 
fbe740
-- 
fbe740
2.26.2
fbe740