]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
node_device_conf: use g_autoptr in virNodeDevCapPCIDevIommuGroupParseXML()
authorKristina Hanicova <khanicov@redhat.com>
Wed, 3 Mar 2021 16:17:26 +0000 (17:17 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Mar 2021 10:52:32 +0000 (11:52 +0100)
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/node_device_conf.c

index cfc72299de407c8211a346007caaf1d6f7b520ba..087dc1dfa09cfd9406b87a08cee64f4d06046958 100644 (file)
@@ -1581,7 +1581,6 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt,
     g_autofree char *numberStr = NULL;
     int nAddrNodes, ret = -1;
     size_t i;
-    virPCIDeviceAddressPtr pciAddr = NULL;
 
     ctxt->node = iommuGroupNode;
 
@@ -1603,14 +1602,10 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt,
         goto cleanup;
 
     for (i = 0; i < nAddrNodes; i++) {
-        virPCIDeviceAddress addr = {0};
-        if (virPCIDeviceAddressParseXML(addrNodes[i], &addr) < 0)
-            goto cleanup;
-        pciAddr = g_new0(virPCIDeviceAddress, 1);
-        pciAddr->domain = addr.domain;
-        pciAddr->bus = addr.bus;
-        pciAddr->slot = addr.slot;
-        pciAddr->function = addr.function;
+        g_autoptr(virPCIDeviceAddress) pciAddr = g_new0(virPCIDeviceAddress, 1);
+
+        if (virPCIDeviceAddressParseXML(addrNodes[i], pciAddr) < 0)
+            return -1;
         if (VIR_APPEND_ELEMENT(pci_dev->iommuGroupDevices,
                                pci_dev->nIommuGroupDevices,
                                pciAddr) < 0)
@@ -1619,7 +1614,6 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt,
 
     ret = 0;
  cleanup:
-    VIR_FREE(pciAddr);
     return ret;
 }