[libvirt PATCH 09/39] cpu_x86: Use g_auto* in x86VendorParse

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/cpu/cpu_x86.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index d0ef66f1e3..a678bcde61 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -849,9 +849,8 @@ x86VendorParse(xmlXPathContextPtr ctxt,
                void *data)
 {
     virCPUx86MapPtr map = data;
-    virCPUx86VendorPtr vendor = NULL;
-    char *string = NULL;
-    int ret = -1;
+    g_autoptr(virCPUx86Vendor) vendor = NULL;
+    g_autofree char *string = NULL;
 
     vendor = g_new0(virCPUx86Vendor, 1);
     vendor->name = g_strdup(name);
@@ -859,7 +858,7 @@ x86VendorParse(xmlXPathContextPtr ctxt,
     if (x86VendorFind(map, vendor->name)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("CPU vendor %s already defined"), vendor->name);
-        goto cleanup;
+        return -1;
     }
 
     string = virXPathString("string(@string)", ctxt);
@@ -867,21 +866,16 @@ x86VendorParse(xmlXPathContextPtr ctxt,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Missing vendor string for CPU vendor %s"),
                        vendor->name);
-        goto cleanup;
+        return -1;
     }
 
     if (virCPUx86VendorToData(string, &vendor->data) < 0)
-        goto cleanup;
+        return -1;
 
     if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    x86VendorFree(vendor);
-    VIR_FREE(string);
-    return ret;
+    return 0;
 }
 
 
-- 
2.26.0





[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