diff options
author | hselasky <hselasky@FreeBSD.org> | 2011-12-03 16:30:47 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2011-12-03 16:30:47 +0000 |
commit | 9151a2a45f37ad87d31fee1a0bff53f78be58936 (patch) | |
tree | d3a2db1a96b9f0c37b7f4547a21734cb75b3a522 /lib/libusb/libusb10.c | |
parent | fe7036d97d6db0c265b31a2ed29c141ec4848970 (diff) | |
download | FreeBSD-src-9151a2a45f37ad87d31fee1a0bff53f78be58936.zip FreeBSD-src-9151a2a45f37ad87d31fee1a0bff53f78be58936.tar.gz |
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
Diffstat (limited to 'lib/libusb/libusb10.c')
-rw-r--r-- | lib/libusb/libusb10.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index f1b95d6..0be318a 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -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) return (NULL); + pdev = NULL; for (j = 0; j < i; j++) { - pdev = devs[j]->os_priv; - pdesc = libusb20_dev_get_device_desc(pdev); + struct libusb20_device *tdev; + + tdev = devs[j]->os_priv; + pdesc = libusb20_dev_get_device_desc(tdev); /* * NOTE: The USB library will automatically swap the * 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; } } - if (j == i) - pdev = NULL; libusb_free_device_list(devs, 1); DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave"); |