laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/43346?usp=email )

Change subject: usb: osmo_libusb_open_claim_interface: print an error when no 
device was found
......................................................................

usb: osmo_libusb_open_claim_interface: print an error when no device was found

When no device was found, osmo_libusb_open_claim_interface() was silent
and the other had no idea what went wrong.

Change-Id: I59d31f80a9d5b6bf7b33ca80f4387748531b4cce
---
M src/usb/osmo_libusb.c
1 file changed, 8 insertions(+), 5 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/src/usb/osmo_libusb.c b/src/usb/osmo_libusb.c
index a249d10..e08a607 100644
--- a/src/usb/osmo_libusb.c
+++ b/src/usb/osmo_libusb.c
@@ -543,14 +543,14 @@
                        if (rc < 0) {
                                fprintf(stderr, "Cannot open device: %s\n", 
libusb_error_name(rc));
                                usb_devh = NULL;
-                               break;
+                               goto out;
                        }
                        rc = libusb_get_configuration(usb_devh, &config);
                        if (rc < 0) {
                                fprintf(stderr, "Cannot get current 
configuration: %s\n", libusb_error_name(rc));
                                libusb_close(usb_devh);
                                usb_devh = NULL;
-                               break;
+                               goto out;
                        }
                        if (config != ifm->configuration) {
                                rc = libusb_set_configuration(usb_devh, 
ifm->configuration);
@@ -558,7 +558,7 @@
                                        fprintf(stderr, "Cannot set 
configuration: %s\n", libusb_error_name(rc));
                                        libusb_close(usb_devh);
                                        usb_devh = NULL;
-                                       break;
+                                       goto out;
                                }
                        }
                        rc = libusb_claim_interface(usb_devh, ifm->interface);
@@ -566,7 +566,7 @@
                                fprintf(stderr, "Cannot claim interface: %s\n", 
libusb_error_name(rc));
                                libusb_close(usb_devh);
                                usb_devh = NULL;
-                               break;
+                               goto out;
                        }
                        rc = libusb_set_interface_alt_setting(usb_devh, 
ifm->interface, ifm->altsetting);
                        if (rc < 0) {
@@ -574,11 +574,14 @@
                                libusb_release_interface(usb_devh, 
ifm->interface);
                                libusb_close(usb_devh);
                                usb_devh = NULL;
-                               break;
+                               goto out;
                        }
                }
        }

+       if (!usb_devh)
+               fprintf(stderr, "Failed to find a matching usb device\n");
+out:
        /* unref / free list */
        for (dev = list; *dev; dev++)
                libusb_unref_device(*dev);

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/43346?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I59d31f80a9d5b6bf7b33ca80f4387748531b4cce
Gerrit-Change-Number: 43346
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to