]> sigrok.org Git - libserialport.git/commitdiff
windows: Fix another CreateFile usage.
authorMartin Ling <redacted>
Fri, 24 Jan 2020 05:14:47 +0000 (05:14 +0000)
committerUwe Hermann <redacted>
Sun, 26 Jan 2020 20:11:46 +0000 (21:11 +0100)
When built with MSVC with unicode enabled, this gave:

warning C4133: 'function': incompatible types - from 'char *' to 'LPCWSTR'

due to CreateFile expanding to CreateFileW which accepts UTF-16 filenames.

The device name used here is in 8-bit format, having come from a call to
wc_to_utf8() in either get_root_hub_name() or get_external_hub_name(). So
we need to use CreateFileA.

windows.c

index f9c2c41faf768925e6eb38b0a1784150f283cc6c..2825a92082672a3c05aa5997390dc5d25f5b00b7 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -265,8 +265,8 @@ static void enumerate_hub(struct sp_port *port, const char *hub_name,
                return;
        strcpy(device_name, "\\\\.\\");
        strcat(device_name, hub_name);
-       hub_device = CreateFile(device_name, GENERIC_WRITE, FILE_SHARE_WRITE,
-                               NULL, OPEN_EXISTING, 0, NULL);
+       hub_device = CreateFileA(device_name, GENERIC_WRITE, FILE_SHARE_WRITE,
+                                NULL, OPEN_EXISTING, 0, NULL);
        free(device_name);
        if (hub_device == INVALID_HANDLE_VALUE)
                return;