]> git.sur5r.net Git - openocd/commitdiff
libusb: idProduct of USB device may be zero
authorHsiangkai Wang <Hsiangkai@gmail.com>
Wed, 26 Dec 2012 09:32:10 +0000 (17:32 +0800)
committerFreddie Chopin <freddie.chopin@gmail.com>
Sun, 27 Jan 2013 14:14:21 +0000 (14:14 +0000)
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>
src/jtag/drivers/libusb0_common.c
src/jtag/drivers/libusb1_common.c

index c731ee54526f484a5fbab398feaade22ecb8e697..9662803f8391248e39a83027c1b52473248c339e 100644 (file)
@@ -28,7 +28,7 @@
 static bool jtag_libusb_match(struct jtag_libusb_device *dev,
                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] &&
                        dev->descriptor.idProduct == pids[i]) {
                        return true;
index 194f737cde3a9f87955b2ec594d85765e3c6051c..dc6c0a7252ad7beba3a74c0f25bd4e95128f13ea 100644 (file)
@@ -33,7 +33,7 @@ static bool jtag_libusb_match(struct jtag_libusb_device *dev,
 {
        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 (dev_desc.idVendor == vids[i] &&
                                dev_desc.idProduct == pids[i])