Simplify libusb_open_device_with_vid_pid(): Only set
pdev to non-NULL on success instead of unconditonally setting it and maybe resetting it later. Submitted by: Christoph Mallon MFC after: 3 days
This commit is contained in:
parent
dc93480306
commit
3f709d07c5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=228236
@ -417,9 +417,12 @@ libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id,
|
|||||||
if ((i = libusb_get_device_list(ctx, &devs)) < 0)
|
if ((i = libusb_get_device_list(ctx, &devs)) < 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
|
pdev = NULL;
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
pdev = devs[j]->os_priv;
|
struct libusb20_device *tdev;
|
||||||
pdesc = libusb20_dev_get_device_desc(pdev);
|
|
||||||
|
tdev = devs[j]->os_priv;
|
||||||
|
pdesc = libusb20_dev_get_device_desc(tdev);
|
||||||
/*
|
/*
|
||||||
* NOTE: The USB library will automatically swap the
|
* NOTE: The USB library will automatically swap the
|
||||||
* fields in the device descriptor to be of host
|
* fields in the device descriptor to be of host
|
||||||
@ -431,8 +434,6 @@ libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j == i)
|
|
||||||
pdev = NULL;
|
|
||||||
|
|
||||||
libusb_free_device_list(devs, 1);
|
libusb_free_device_list(devs, 1);
|
||||||
DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave");
|
DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave");
|
||||||
|
Loading…
Reference in New Issue
Block a user