From 69a66f13196d21a3dac06b9e0cf0db77e5e467fe Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 17 Sep 2019 11:20:42 +0200 Subject: [PATCH] qemu_domain: Drop few useless checks in qemuDomainGetHostdevPath 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 Reviewed-by: Cole Robinson --- 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 387cea8791..c5ef3cb417 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12802,8 +12802,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; @@ -12824,8 +12823,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; } @@ -12837,8 +12835,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.47.2