libusb: idProduct of USB device may be zero
There is no constraint about idProduct in USB spec. So, pids[i] may be 0 for USB devices. Change-Id: I19d8974f4e7082e8b7e1f2d33c019ac4e61bc1e2 Signed-off-by: Hsiangkai Wang <hsiangkai@gmail.com> Reviewed-on: http://openocd.zylin.com/1091 Tested-by: jenkins Reviewed-by: Xiaofan <xiaofanc@gmail.com> Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
This commit is contained in:
parent
3eb7d77601
commit
f807d6ab3d
|
@ -28,7 +28,7 @@
|
||||||
static bool jtag_libusb_match(struct jtag_libusb_device *dev,
|
static bool jtag_libusb_match(struct jtag_libusb_device *dev,
|
||||||
const uint16_t vids[], const uint16_t pids[])
|
const uint16_t vids[], const uint16_t pids[])
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; vids[i] && pids[i]; i++) {
|
for (unsigned i = 0; vids[i]; i++) {
|
||||||
if (dev->descriptor.idVendor == vids[i] &&
|
if (dev->descriptor.idVendor == vids[i] &&
|
||||||
dev->descriptor.idProduct == pids[i]) {
|
dev->descriptor.idProduct == pids[i]) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -33,7 +33,7 @@ static bool jtag_libusb_match(struct jtag_libusb_device *dev,
|
||||||
{
|
{
|
||||||
struct libusb_device_descriptor dev_desc;
|
struct libusb_device_descriptor dev_desc;
|
||||||
|
|
||||||
for (unsigned i = 0; vids[i] && pids[i]; i++) {
|
for (unsigned i = 0; vids[i]; i++) {
|
||||||
if (libusb_get_device_descriptor(dev, &dev_desc) == 0) {
|
if (libusb_get_device_descriptor(dev, &dev_desc) == 0) {
|
||||||
if (dev_desc.idVendor == vids[i] &&
|
if (dev_desc.idVendor == vids[i] &&
|
||||||
dev_desc.idProduct == pids[i])
|
dev_desc.idProduct == pids[i])
|
||||||
|
|
Loading…
Reference in New Issue