lynxis lazus has uploaded this change for review.

View Change

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(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/46/43346/1
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 change 43346. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I59d31f80a9d5b6bf7b33ca80f4387748531b4cce
Gerrit-Change-Number: 43346
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis@fe80.eu>