blob: 1163b5c0bc541b9fa622e4afd675791a4ccbb87e [file] [log] [blame]
commit fd034a7aaa0f76cbaf65c8933f05e53f0e6e4f2c
Author: Fletcher Woodruff <fletcherw@chromium.org>
Date: Tue Jun 16 13:59:10 2020 -0600
Log errno when acquiring usb connection fails
diff --git a/src/usb.c b/src/usb.c
index aa05960..905b90b 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -19,6 +19,7 @@
#include <time.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include <libusb.h>
@@ -686,9 +687,17 @@ struct usb_conn_t *usb_conn_acquire(struct usb_sock_t *usb)
/* Sanity check: Is the interface still free */
if (sem_trywait(&uf->lock)) {
- ERR("Interface #%d (%d) already in use!",
- conn->interface_index,
- uf->libusb_interface_index);
+ int error = errno;
+ if (error == EAGAIN) {
+ ERR("Interface #%d (%d) already in use!",
+ conn->interface_index,
+ uf->libusb_interface_index);
+ } else {
+ ERR("sem_trywait on interface #%d (%d) failed with error %d",
+ conn->interface_index,
+ uf->libusb_interface_index,
+ error);
+ }
goto acquire_error;
}