提交 c74fadd2 编写于 作者: S Sukrit Bhatnagar 提交者: Erik Skultety

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: NSukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 00dc991c
......@@ -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;
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册