Windows: Fix timeouts if only endpoint 0 exists
The default timeouts of 5 seconds used by WinUSB are cleared in
configure_endpoints(). This was not called if not at least one extra
endpoint apart from endpoint 0 existed, so that in those cases the
default timeout of 5 seconds remained in place.
Fix this by calling configure_endpoints, even if no interface specific
endpoints were found, so that it can configure endpoint 0.
Closes #963
Signed-off-by: Julian Scheel <julian@jusst.de>
[Tormod: Refactored to reduce duplicated code]
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
index 5c860ea..df17d81 100644
--- a/libusb/os/windows_winusb.c
+++ b/libusb/os/windows_winusb.c
@@ -528,21 +528,17 @@
if (if_desc->bNumEndpoints == 0) {
usbi_dbg(HANDLE_CTX(dev_handle), "no endpoints found for interface %u", iface);
- libusb_free_config_descriptor(conf_desc);
- priv->usb_interface[iface].current_altsetting = altsetting;
- return LIBUSB_SUCCESS;
- }
-
- priv->usb_interface[iface].endpoint = malloc(if_desc->bNumEndpoints);
- if (priv->usb_interface[iface].endpoint == NULL) {
- libusb_free_config_descriptor(conf_desc);
- return LIBUSB_ERROR_NO_MEM;
- }
-
- priv->usb_interface[iface].nb_endpoints = if_desc->bNumEndpoints;
- for (i = 0; i < if_desc->bNumEndpoints; i++) {
- priv->usb_interface[iface].endpoint[i] = if_desc->endpoint[i].bEndpointAddress;
- usbi_dbg(HANDLE_CTX(dev_handle), "(re)assigned endpoint %02X to interface %u", priv->usb_interface[iface].endpoint[i], iface);
+ } else {
+ priv->usb_interface[iface].endpoint = malloc(if_desc->bNumEndpoints);
+ if (priv->usb_interface[iface].endpoint == NULL) {
+ libusb_free_config_descriptor(conf_desc);
+ return LIBUSB_ERROR_NO_MEM;
+ }
+ priv->usb_interface[iface].nb_endpoints = if_desc->bNumEndpoints;
+ for (i = 0; i < if_desc->bNumEndpoints; i++) {
+ priv->usb_interface[iface].endpoint[i] = if_desc->endpoint[i].bEndpointAddress;
+ usbi_dbg(HANDLE_CTX(dev_handle), "(re)assigned endpoint %02X to interface %u", priv->usb_interface[iface].endpoint[i], iface);
+ }
}
libusb_free_config_descriptor(conf_desc);
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index c65a80b..838c0a6 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11672
+#define LIBUSB_NANO 11673