]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu_map: Use g_auto* in cpuMapLoadInclude
authorTim Wiederhake <twiederh@redhat.com>
Mon, 7 Sep 2020 14:58:53 +0000 (16:58 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 8 Sep 2020 15:41:22 +0000 (17:41 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_map.c

index cbf90d1395f3fdee2758bc373df4922fe7d3c4a7..b0b3ce84310c62046b7ee1f985b61850c4d012f3 100644 (file)
@@ -85,10 +85,9 @@ cpuMapLoadInclude(const char *filename,
                   cpuMapLoadCallback modelCB,
                   void *data)
 {
-    xmlDocPtr xml = NULL;
-    xmlXPathContextPtr ctxt = NULL;
-    int ret = -1;
-    char *mapfile;
+    g_autoptr(xmlDoc) xml = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
+    g_autofree char *mapfile = NULL;
 
     if (!(mapfile = virFileFindResource(filename,
                                         abs_top_srcdir "/src/cpu_map",
@@ -98,27 +97,20 @@ cpuMapLoadInclude(const char *filename,
     VIR_DEBUG("Loading CPU map include from %s", mapfile);
 
     if (!(xml = virXMLParseFileCtxt(mapfile, &ctxt)))
-        goto cleanup;
+        return -1;
 
     ctxt->node = xmlDocGetRootElement(xml);
 
     if (loadData(mapfile, ctxt, "vendor", vendorCB, data) < 0)
-        goto cleanup;
+        return -1;
 
     if (loadData(mapfile, ctxt, "feature", featureCB, data) < 0)
-        goto cleanup;
+        return -1;
 
     if (loadData(mapfile, ctxt, "model", modelCB, data) < 0)
-        goto cleanup;
-
-    ret = 0;
-
- cleanup:
-    xmlXPathFreeContext(ctxt);
-    xmlFreeDoc(xml);
-    VIR_FREE(mapfile);
+        return -1;
 
-    return ret;
+    return 0;
 }