1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

util: usb: modify virUSBDeviceListAdd to take double pointer

Modify virUSBDeviceListAdd to take a double pointer to
virUSBDevicePtr as the second argument. This will enable usage
of cleanup macros upon the virUSBDevicePtr item which is to be
added to the list as it will be cleared by virInsertElementsN
upon success.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Sukrit Bhatnagar 2018-07-24 21:22:23 +05:30 committed by Erik Skultety
parent 00dc991ca1
commit c74fadd251
4 changed files with 11 additions and 11 deletions

View File

@ -1236,7 +1236,7 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr,
virUSBDeviceSetUsedBy(usb, drv_name, dom_name);
if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0) {
if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, &usb) < 0) {
virUSBDeviceFree(usb);
goto cleanup;
}
@ -1406,7 +1406,7 @@ virHostdevMarkUSBDevices(virHostdevManagerPtr mgr,
* from the virUSBDeviceList that passed in on success,
* perform rollback on failure.
*/
if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0)
if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, &usb) < 0)
goto error;
}
@ -1555,7 +1555,7 @@ virHostdevPrepareUSBDevices(virHostdevManagerPtr mgr,
if (virHostdevFindUSBDevice(hostdev, required, &usb) < 0)
goto cleanup;
if (usb && virUSBDeviceListAdd(list, usb) < 0) {
if (usb && virUSBDeviceListAdd(list, &usb) < 0) {
virUSBDeviceFree(usb);
goto cleanup;
}

View File

@ -181,7 +181,7 @@ virUSBDeviceSearch(unsigned int vendor,
if (!usb)
goto cleanup;
if (virUSBDeviceListAdd(list, usb) < 0) {
if (virUSBDeviceListAdd(list, &usb) < 0) {
virUSBDeviceFree(usb);
goto cleanup;
}
@ -463,15 +463,15 @@ virUSBDeviceListDispose(void *obj)
int
virUSBDeviceListAdd(virUSBDeviceListPtr list,
virUSBDevicePtr dev)
virUSBDevicePtr *dev)
{
if (virUSBDeviceListFind(list, dev)) {
if (virUSBDeviceListFind(list, *dev)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Device %s is already in use"),
dev->name);
(*dev)->name);
return -1;
}
return VIR_APPEND_ELEMENT(list->devs, list->count, dev);
return VIR_APPEND_ELEMENT(list->devs, list->count, *dev);
}
virUSBDevicePtr

View File

@ -88,7 +88,7 @@ int virUSBDeviceFileIterate(virUSBDevicePtr dev,
virUSBDeviceListPtr virUSBDeviceListNew(void);
int virUSBDeviceListAdd(virUSBDeviceListPtr list,
virUSBDevicePtr dev);
virUSBDevicePtr *dev);
virUSBDevicePtr virUSBDeviceListGet(virUSBDeviceListPtr list,
int idx);
size_t virUSBDeviceListCount(virUSBDeviceListPtr list);

View File

@ -173,7 +173,7 @@ testUSBList(const void *opaque ATTRIBUTE_UNUSED)
dev = virUSBDeviceListGet(devlist, 0);
dev = virUSBDeviceListSteal(devlist, dev);
if (virUSBDeviceListAdd(list, dev) < 0)
if (virUSBDeviceListAdd(list, &dev) < 0)
goto cleanup;
dev = NULL;
}
@ -196,7 +196,7 @@ testUSBList(const void *opaque ATTRIBUTE_UNUSED)
dev = virUSBDeviceListGet(devlist, 0);
dev = virUSBDeviceListSteal(devlist, dev);
if (virUSBDeviceListAdd(list, dev) < 0)
if (virUSBDeviceListAdd(list, &dev) < 0)
goto cleanup;
dev = NULL;
}