mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuDomainGetHostdevPath: Drop @freeTmpPath
The @freeTmpPath boolean is used to determine if @tmpPath holds an allocated memory or is a pointer to a constant string and therefore if it needs to be freed or not when returning from the function. Well, we can unify the way we set @tmpPath so that it always holds an allocated memory and thus always must be freed. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
69a66f1319
commit
224d269f19
@ -12758,7 +12758,6 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
|
|||||||
virSCSIDevicePtr scsi = NULL;
|
virSCSIDevicePtr scsi = NULL;
|
||||||
virSCSIVHostDevicePtr host = NULL;
|
virSCSIVHostDevicePtr host = NULL;
|
||||||
char *tmpPath = NULL;
|
char *tmpPath = NULL;
|
||||||
bool freeTmpPath = false;
|
|
||||||
bool includeVFIO = false;
|
bool includeVFIO = false;
|
||||||
char **tmpPaths = NULL;
|
char **tmpPaths = NULL;
|
||||||
int *tmpPerms = NULL;
|
int *tmpPerms = NULL;
|
||||||
@ -12781,7 +12780,6 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
|
|||||||
|
|
||||||
if (!(tmpPath = virPCIDeviceGetIOMMUGroupDev(pci)))
|
if (!(tmpPath = virPCIDeviceGetIOMMUGroupDev(pci)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
freeTmpPath = true;
|
|
||||||
|
|
||||||
perm = VIR_CGROUP_DEVICE_RW;
|
perm = VIR_CGROUP_DEVICE_RW;
|
||||||
if (teardown) {
|
if (teardown) {
|
||||||
@ -12802,7 +12800,8 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
|
|||||||
if (!usb)
|
if (!usb)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
tmpPath = (char *)virUSBDeviceGetPath(usb);
|
if (VIR_STRDUP(tmpPath, virUSBDeviceGetPath(usb)) < 0)
|
||||||
|
goto cleanup;
|
||||||
perm = VIR_CGROUP_DEVICE_RW;
|
perm = VIR_CGROUP_DEVICE_RW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -12823,7 +12822,8 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
|
|||||||
if (!scsi)
|
if (!scsi)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
tmpPath = (char *)virSCSIDeviceGetPath(scsi);
|
if (VIR_STRDUP(tmpPath, virSCSIDeviceGetPath(scsi)) < 0)
|
||||||
|
goto cleanup;
|
||||||
perm = virSCSIDeviceGetReadonly(scsi) ?
|
perm = virSCSIDeviceGetReadonly(scsi) ?
|
||||||
VIR_CGROUP_DEVICE_READ : VIR_CGROUP_DEVICE_RW;
|
VIR_CGROUP_DEVICE_READ : VIR_CGROUP_DEVICE_RW;
|
||||||
}
|
}
|
||||||
@ -12835,7 +12835,8 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
|
|||||||
if (!(host = virSCSIVHostDeviceNew(hostsrc->wwpn)))
|
if (!(host = virSCSIVHostDeviceNew(hostsrc->wwpn)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
tmpPath = (char *)virSCSIVHostDeviceGetPath(host);
|
if (VIR_STRDUP(tmpPath, virSCSIVHostDeviceGetPath(host)) < 0)
|
||||||
|
goto cleanup;
|
||||||
perm = VIR_CGROUP_DEVICE_RW;
|
perm = VIR_CGROUP_DEVICE_RW;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -12845,7 +12846,6 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
|
|||||||
if (!(tmpPath = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
|
if (!(tmpPath = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
freeTmpPath = true;
|
|
||||||
includeVFIO = true;
|
includeVFIO = true;
|
||||||
perm = VIR_CGROUP_DEVICE_RW;
|
perm = VIR_CGROUP_DEVICE_RW;
|
||||||
break;
|
break;
|
||||||
@ -12895,8 +12895,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
|
|||||||
virUSBDeviceFree(usb);
|
virUSBDeviceFree(usb);
|
||||||
virSCSIDeviceFree(scsi);
|
virSCSIDeviceFree(scsi);
|
||||||
virSCSIVHostDeviceFree(host);
|
virSCSIVHostDeviceFree(host);
|
||||||
if (freeTmpPath)
|
VIR_FREE(tmpPath);
|
||||||
VIR_FREE(tmpPath);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user