]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuDomainGetHostdevPath: Use more g_autoptr()/g_autofree
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Sep 2019 09:31:24 +0000 (11:31 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Dec 2019 09:04:43 +0000 (10:04 +0100)
There are several variables which could be automatically freed
upon return from the function. I'm not changing @tmpPaths (which
is a string list) because it is going to be removed in next
commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/qemu/qemu_domain.c

index 88509ce9aee4984a77dcef3e7b1210ab933757dc..5d2758bc197ec7f7905e76a019d662f4f7194321 100644 (file)
@@ -13852,14 +13852,14 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
     virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
     virDomainHostdevSubsysSCSIVHostPtr hostsrc = &dev->source.subsys.u.scsi_host;
     virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev;
-    virPCIDevicePtr pci = NULL;
-    virUSBDevicePtr usb = NULL;
-    virSCSIDevicePtr scsi = NULL;
-    virSCSIVHostDevicePtr host = NULL;
-    char *tmpPath = NULL;
+    g_autoptr(virPCIDevice) pci = NULL;
+    g_autoptr(virUSBDevice) usb = NULL;
+    g_autoptr(virSCSIDevice) scsi = NULL;
+    g_autoptr(virSCSIVHostDevice) host = NULL;
+    g_autofree char *tmpPath = NULL;
     bool includeVFIO = false;
     char **tmpPaths = NULL;
-    int *tmpPerms = NULL;
+    g_autofree int *tmpPerms = NULL;
     size_t tmpNpaths = 0;
     int perm = 0;
 
@@ -13986,12 +13986,6 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
     ret = 0;
  cleanup:
     virStringListFreeCount(tmpPaths, tmpNpaths);
-    VIR_FREE(tmpPerms);
-    virPCIDeviceFree(pci);
-    virUSBDeviceFree(usb);
-    virSCSIDeviceFree(scsi);
-    virSCSIVHostDeviceFree(host);
-    VIR_FREE(tmpPath);
     return ret;
 }