Ensure that the USB device search succeeds if the matched device is at index 0.
authorkevin <software@klystron.com>
Tue, 7 May 2013 12:33:58 +0000 (13:33 +0100)
committerkevin <software@klystron.com>
Tue, 7 May 2013 12:33:58 +0000 (13:33 +0100)
src/stlink-usb.c

index 825ee0aeaf3897caae788b7aab16a42aae88b228..d574584281e3f5668c532b84a75aba33cd81edc1 100644 (file)
@@ -757,9 +757,9 @@ stlink_t* stlink_open_usb(const int verbose) {
         if (desc.idProduct == USB_STLINK_PID) slu->protocoll = 1; break;
     }
     
-    if (cnt==0){
-       WLOG("Couldn't find %s ST-Link/V2 devices\n",(devBus && devAddr)?"matched":"any");
-       goto on_error;
+    if (cnt < 0) {
+           WLOG ("Couldn't find %s ST-Link/V2 devices\n",(devBus && devAddr)?"matched":"any");
+           goto on_error;
     } else {
        if( libusb_open(list[cnt], &slu->usb_handle) !=0){
            WLOG("Couldn't open ST-Link/V2 device %03d:%03d\n",libusb_get_bus_number(list[cnt]), libusb_get_device_address(list[cnt]));