mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-02 04:15:46 +00: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:
parent
00dc991ca1
commit
c74fadd251
@ -1236,7 +1236,7 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr,
|
|||||||
|
|
||||||
virUSBDeviceSetUsedBy(usb, drv_name, dom_name);
|
virUSBDeviceSetUsedBy(usb, drv_name, dom_name);
|
||||||
|
|
||||||
if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0) {
|
if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, &usb) < 0) {
|
||||||
virUSBDeviceFree(usb);
|
virUSBDeviceFree(usb);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1406,7 +1406,7 @@ virHostdevMarkUSBDevices(virHostdevManagerPtr mgr,
|
|||||||
* from the virUSBDeviceList that passed in on success,
|
* from the virUSBDeviceList that passed in on success,
|
||||||
* perform rollback on failure.
|
* perform rollback on failure.
|
||||||
*/
|
*/
|
||||||
if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0)
|
if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, &usb) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1555,7 +1555,7 @@ virHostdevPrepareUSBDevices(virHostdevManagerPtr mgr,
|
|||||||
if (virHostdevFindUSBDevice(hostdev, required, &usb) < 0)
|
if (virHostdevFindUSBDevice(hostdev, required, &usb) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (usb && virUSBDeviceListAdd(list, usb) < 0) {
|
if (usb && virUSBDeviceListAdd(list, &usb) < 0) {
|
||||||
virUSBDeviceFree(usb);
|
virUSBDeviceFree(usb);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ virUSBDeviceSearch(unsigned int vendor,
|
|||||||
if (!usb)
|
if (!usb)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virUSBDeviceListAdd(list, usb) < 0) {
|
if (virUSBDeviceListAdd(list, &usb) < 0) {
|
||||||
virUSBDeviceFree(usb);
|
virUSBDeviceFree(usb);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -463,15 +463,15 @@ virUSBDeviceListDispose(void *obj)
|
|||||||
|
|
||||||
int
|
int
|
||||||
virUSBDeviceListAdd(virUSBDeviceListPtr list,
|
virUSBDeviceListAdd(virUSBDeviceListPtr list,
|
||||||
virUSBDevicePtr dev)
|
virUSBDevicePtr *dev)
|
||||||
{
|
{
|
||||||
if (virUSBDeviceListFind(list, dev)) {
|
if (virUSBDeviceListFind(list, *dev)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Device %s is already in use"),
|
_("Device %s is already in use"),
|
||||||
dev->name);
|
(*dev)->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return VIR_APPEND_ELEMENT(list->devs, list->count, dev);
|
return VIR_APPEND_ELEMENT(list->devs, list->count, *dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
virUSBDevicePtr
|
virUSBDevicePtr
|
||||||
|
@ -88,7 +88,7 @@ int virUSBDeviceFileIterate(virUSBDevicePtr dev,
|
|||||||
|
|
||||||
virUSBDeviceListPtr virUSBDeviceListNew(void);
|
virUSBDeviceListPtr virUSBDeviceListNew(void);
|
||||||
int virUSBDeviceListAdd(virUSBDeviceListPtr list,
|
int virUSBDeviceListAdd(virUSBDeviceListPtr list,
|
||||||
virUSBDevicePtr dev);
|
virUSBDevicePtr *dev);
|
||||||
virUSBDevicePtr virUSBDeviceListGet(virUSBDeviceListPtr list,
|
virUSBDevicePtr virUSBDeviceListGet(virUSBDeviceListPtr list,
|
||||||
int idx);
|
int idx);
|
||||||
size_t virUSBDeviceListCount(virUSBDeviceListPtr list);
|
size_t virUSBDeviceListCount(virUSBDeviceListPtr list);
|
||||||
|
@ -173,7 +173,7 @@ testUSBList(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
dev = virUSBDeviceListGet(devlist, 0);
|
dev = virUSBDeviceListGet(devlist, 0);
|
||||||
dev = virUSBDeviceListSteal(devlist, dev);
|
dev = virUSBDeviceListSteal(devlist, dev);
|
||||||
|
|
||||||
if (virUSBDeviceListAdd(list, dev) < 0)
|
if (virUSBDeviceListAdd(list, &dev) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
dev = NULL;
|
dev = NULL;
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ testUSBList(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
dev = virUSBDeviceListGet(devlist, 0);
|
dev = virUSBDeviceListGet(devlist, 0);
|
||||||
dev = virUSBDeviceListSteal(devlist, dev);
|
dev = virUSBDeviceListSteal(devlist, dev);
|
||||||
|
|
||||||
if (virUSBDeviceListAdd(list, dev) < 0)
|
if (virUSBDeviceListAdd(list, &dev) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
dev = NULL;
|
dev = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user