From: Martin Ling Date: Fri, 24 Jan 2020 05:14:47 +0000 (+0000) Subject: windows: Fix another CreateFile usage. X-Git-Tag: libserialport-0.1.2~37 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d6412d280180ed87cb07578d5d15d09d775b9f7d;p=libserialport.git windows: Fix another CreateFile usage. 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. --- diff --git a/windows.c b/windows.c index f9c2c41..2825a92 100644 --- 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;