[PATCH v2 08/39] qemu_domain: Drop few useless checks in qemuDomainGetHostdevPath

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

 



There are three cases where vir*DeviceGetPath() returns a const
string. In these cases, the string is initialized in
corresponding vir*DeviceNew() calls which fail if string couldn't
be allocated. There's no point in checking the second time if the
string is NULL.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 02b6e590cd..ca6de24e68 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -12915,8 +12915,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
             if (!usb)
                 goto cleanup;
 
-            if (!(tmpPath = (char *)virUSBDeviceGetPath(usb)))
-                goto cleanup;
+            tmpPath = (char *)virUSBDeviceGetPath(usb);
             perm = VIR_CGROUP_DEVICE_RW;
             break;
 
@@ -12937,8 +12936,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
                 if (!scsi)
                     goto cleanup;
 
-                if (!(tmpPath = (char *)virSCSIDeviceGetPath(scsi)))
-                    goto cleanup;
+                tmpPath = (char *)virSCSIDeviceGetPath(scsi);
                 perm = virSCSIDeviceGetReadonly(scsi) ?
                     VIR_CGROUP_DEVICE_READ : VIR_CGROUP_DEVICE_RW;
             }
@@ -12950,8 +12948,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
                 if (!(host = virSCSIVHostDeviceNew(hostsrc->wwpn)))
                     goto cleanup;
 
-                if (!(tmpPath = (char *)virSCSIVHostDeviceGetPath(host)))
-                    goto cleanup;
+                tmpPath = (char *)virSCSIVHostDeviceGetPath(host);
                 perm = VIR_CGROUP_DEVICE_RW;
             }
             break;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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