libftdi Archives

Subject: [PATCH Fixed first device failure in open_desc function v3 2/2] action review comments

From: Harrison Marcks <hmarcks@xxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Harrison Marcks <hmarcks@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Oct 2022 13:18:15 +0100
remove diagnostic buf
remove open_counter and open_fail_counter
---
 src/ftdi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index c64fd8e..5854f49 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -781,7 +781,6 @@ int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int 
vendor, int product,
     char string[256];
     int i = 0;
     int error_code = -3;
-    int open_counter = 0, open_fail_counter = 0;
 
     if (ftdi == NULL)
         ftdi_error_return(-11, "ftdi context invalid");
@@ -799,10 +798,8 @@ int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, 
int vendor, int product,
 
         if (desc.idVendor == vendor && desc.idProduct == product)
         {
-            open_counter++;
             if (libusb_open(dev, &ftdi->usb_dev) < 0)
             {
-                open_fail_counter++;
                 error_code = -4;
                 continue;
             }
@@ -858,9 +855,7 @@ int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int 
vendor, int product,
         case -4:
         {
             // Failure to open any devices. We made at least one match and it 
failed to open.
-            char buf [256];
-            sprintf(buf, "usb_open() ran %d times and failed %d times.", 
open_counter, open_fail_counter);
-            ftdi_error_return_free_device_list(-4, buf, devs);
+            ftdi_error_return_free_device_list(-4, "usb_open() has failed to 
open devices", devs);
         }
         break;
     }
-- 
2.34.1


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread