mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
virHostdevFindUSBDevice: Simplify flow a bit
When looking up a USB device by vendor the virUSBDeviceFindByVendor() is used. The function returns number of items found. But the logic in caller to process it is needlessly complicated. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f08e6883cb
commit
35d61939bc
@ -1400,15 +1400,9 @@ virHostdevFindUSBDevice(virDomainHostdevDefPtr hostdev,
|
||||
VIR_AUTOUNREF(virUSBDeviceListPtr) devs = NULL;
|
||||
|
||||
rc = virUSBDeviceFindByVendor(vendor, product, NULL, mandatory, &devs);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return -1;
|
||||
|
||||
if (rc == 1) {
|
||||
*usb = virUSBDeviceListGet(devs, 0);
|
||||
virUSBDeviceListSteal(devs, *usb);
|
||||
}
|
||||
|
||||
if (rc == 0) {
|
||||
} else if (rc == 0) {
|
||||
goto out;
|
||||
} else if (rc > 1) {
|
||||
if (autoAddress) {
|
||||
@ -1425,6 +1419,9 @@ virHostdevFindUSBDevice(virDomainHostdevDefPtr hostdev,
|
||||
return -1;
|
||||
}
|
||||
|
||||
*usb = virUSBDeviceListGet(devs, 0);
|
||||
virUSBDeviceListSteal(devs, *usb);
|
||||
|
||||
usbsrc->bus = virUSBDeviceGetBus(*usb);
|
||||
usbsrc->device = virUSBDeviceGetDevno(*usb);
|
||||
usbsrc->autoAddress = true;
|
||||
|
Loading…
Reference in New Issue
Block a user