Windows: Fix some harmless build warnings
authorChris Dickens <christopher.a.dickens@gmail.com>
Tue, 10 Mar 2020 06:06:17 +0000 (23:06 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Tue, 10 Mar 2020 06:06:17 +0000 (23:06 -0700)
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/windows_common.c
libusb/os/windows_winusb.c
libusb/os/windows_winusb.h
libusb/version_nano.h
msvc/config.h

index 4cf0cdf..370ea60 100644 (file)
@@ -457,7 +457,7 @@ static int windows_init(struct libusb_context *ctx)
        int r = LIBUSB_ERROR_OTHER;
        bool winusb_backend_init = false;
 
-       sprintf(mutex_name, "libusb_init%08X", (unsigned int)(GetCurrentProcessId() & 0xFFFFFFFFU));
+       sprintf(mutex_name, "libusb_init%08lX", ULONG_CAST(GetCurrentProcessId() & 0xFFFFFFFFU));
        mutex = CreateMutexA(NULL, FALSE, mutex_name);
        if (mutex == NULL) {
                usbi_err(ctx, "could not create mutex: %s", windows_error_str(0));
@@ -527,7 +527,7 @@ static void windows_exit(struct libusb_context *ctx)
        char mutex_name[11 + 8 + 1]; // strlen("libusb_init") + (32-bit hex PID) + '\0'
        HANDLE mutex;
 
-       sprintf(mutex_name, "libusb_init%08lX", (GetCurrentProcessId() & 0xFFFFFFFFU));
+       sprintf(mutex_name, "libusb_init%08lX", ULONG_CAST(GetCurrentProcessId() & 0xFFFFFFFFU));
        mutex = CreateMutexA(NULL, FALSE, mutex_name);
        if (mutex == NULL)
                return;
index db85d85..ef6fbd2 100644 (file)
@@ -1038,7 +1038,7 @@ static int set_composite_interface(struct libusb_context *ctx, struct libusb_dev
        // devices will have only MI_00 & MI_03 for instance), we retrieve the actual
        // interface number from the path's MI value
        mi_str = strstr(device_id, "MI_");
-       if ((mi_str != NULL) && isdigit(mi_str[3]) && isdigit(mi_str[4])) {
+       if ((mi_str != NULL) && isdigit((unsigned char)mi_str[3]) && isdigit((unsigned char)mi_str[4])) {
                interface_number = ((mi_str[3] - '0') * 10) + (mi_str[4] - '0');
        } else {
                usbi_warn(ctx, "failure to read interface number for %s, using default value", device_id);
index 9f6eb9b..c8d3f15 100644 (file)
@@ -27,7 +27,6 @@
 
 #if defined(_MSC_VER)
 // disable /W4 MSVC warnings that are benign
-#pragma warning(disable:4201)  // nameless struct/union
 #pragma warning(disable:4214)  // bit field types other than int
 #endif
 
index b39f8b1..e949678 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11462
+#define LIBUSB_NANO 11463
index 25eb6e2..2ca5fb2 100644 (file)
@@ -19,6 +19,8 @@
 #pragma warning(disable:4127)
 /* Disable: warning C4200: nonstandard extension used : zero-sized array in struct/union */
 #pragma warning(disable:4200)
+/* Disable: warning C4201: nonstandard extension used : nameless struct/union */
+#pragma warning(disable:4201)
 /* Disable: warning C4324: structure was padded due to __declspec(align()) */
 #pragma warning(disable:4324)
 /* Disable: warning C4996: 'GetVersionExA': was declared deprecated */