]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Use g_auto* in x86VendorParse
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Mar 2020 09:38:04 +0000 (10:38 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 8 Apr 2020 15:41:00 +0000 (17:41 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index be4f40f470e1e37bffd6d8ce212bb02688453995..94a5551000e920f68a4be29ebe34215042387a6c 100644 (file)
@@ -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;
 }