Windows: Always search for "USB" PnP enumerator class
authorChris Dickens <christopher.a.dickens@gmail.com>
Fri, 2 Feb 2018 07:31:18 +0000 (23:31 -0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Fri, 2 Feb 2018 07:31:18 +0000 (23:31 -0800)
On systems running Windows 7 and earlier that only have a USB 3.0 host
controller, devices may not be listed correctly if the root hub PnP
enumerator is anything other than "USB". This regression was introduced
in the recent enumeration refactoring (commit 71a779d07).

Closes #385

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/windows_winusb.c
libusb/version_nano.h

index 64c0a91..180affb 100644 (file)
@@ -1132,8 +1132,8 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
        unsigned int guid_size = GUID_SIZE_STEP;
        unsigned int nb_guids;
        // Keep a list of PnP enumerator strings that are found
-       char *usb_enumerator[8];
-       unsigned int nb_usb_enumerators = 0;
+       char *usb_enumerator[8] = { "USB" };
+       unsigned int nb_usb_enumerators = 1;
        unsigned int usb_enum_index = 0;
        // Keep a list of newly allocated devs to unref
 #define UNREF_SIZE_STEP 16
@@ -1512,7 +1512,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
        free((void *)guid_list);
 
        // Free any PnP enumerator strings
-       for (i = 0; i < nb_usb_enumerators; i++)
+       for (i = 1; i < nb_usb_enumerators; i++)
                free(usb_enumerator[i]);
 
        // Unref newly allocated devs
index 395c39f..e40a0dd 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11297
+#define LIBUSB_NANO 11298