Windows: Fix some MinGW build warnings and printf format specifiers
authorChris Dickens <christopher.a.dickens@gmail.com>
Wed, 22 Jan 2020 00:43:32 +0000 (16:43 -0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Wed, 22 Jan 2020 00:43:32 +0000 (16:43 -0800)
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/poll_windows.c
libusb/os/windows_common.c
libusb/os/windows_winusb.c
libusb/version_nano.h

index 2a3734a..b256d69 100644 (file)
@@ -60,7 +60,7 @@ static size_t fd_count;
 static size_t fd_size;
 #define INC_FDS_EACH 256
 
-static void usbi_dec_fd_table()
+static void usbi_dec_fd_table(void)
 {
        fd_count--;
        if (fd_count == 0) {
index e69d0b0..c170f43 100644 (file)
@@ -81,7 +81,7 @@ const char *windows_error_str(DWORD error_code)
        if (error_code == 0)
                error_code = GetLastError();
 
-       len = sprintf(err_string, "[%u] ", (unsigned int)error_code);
+       len = sprintf(err_string, "[%lu] ", error_code);
 
        // Translate codes returned by SetupAPI. The ones we are dealing with are either
        // in 0x0000xxxx or 0xE000xxxx and can be distinguished from standard error codes.
@@ -104,10 +104,10 @@ const char *windows_error_str(DWORD error_code)
                DWORD format_error = GetLastError();
                if (format_error)
                        snprintf(err_string, sizeof(err_string),
-                               "Windows error code %u (FormatMessage error code %u)",
-                               (unsigned int)error_code, (unsigned int)format_error);
+                               "Windows error code %lu (FormatMessage error code %lu)",
+                               error_code, format_error);
                else
-                       snprintf(err_string, sizeof(err_string), "Unknown error code %u", (unsigned int)error_code);
+                       snprintf(err_string, sizeof(err_string), "Unknown error code %lu", error_code);
        } else {
                // Remove CRLF from end of message, if present
                size_t pos = len + size - 2;
@@ -527,7 +527,7 @@ static void windows_transfer_callback(const struct windows_backend *backend,
 {
        int status, istatus;
 
-       usbi_dbg("handling I/O completion with errcode %u, size %u", (unsigned int)io_result, (unsigned int)io_size);
+       usbi_dbg("handling I/O completion with errcode %lu, size %lu", io_result, io_size);
 
        switch (io_result) {
        case NO_ERROR:
@@ -555,7 +555,7 @@ static void windows_transfer_callback(const struct windows_backend *backend,
                status = LIBUSB_TRANSFER_NO_DEVICE;
                break;
        default:
-               usbi_err(ITRANSFER_CTX(itransfer), "detected I/O error %u: %s", (unsigned int)io_result, windows_error_str(io_result));
+               usbi_err(ITRANSFER_CTX(itransfer), "detected I/O error %lu: %s", io_result, windows_error_str(io_result));
                status = LIBUSB_TRANSFER_ERROR;
                break;
        }
@@ -674,7 +674,7 @@ static void windows_exit(struct libusb_context *ctx)
        char sem_name[11 + 8 + 1]; // strlen("libusb_init") + (32-bit hex PID) + '\0'
        UNUSED(ctx);
 
-       sprintf(sem_name, "libusb_init%08X", (unsigned int)(GetCurrentProcessId() & 0xFFFFFFFF));
+       sprintf(sem_name, "libusb_init%08lX", (GetCurrentProcessId() & 0xFFFFFFFFUL));
        semaphore = CreateSemaphoreA(NULL, 1, 1, sem_name);
        if (semaphore == NULL)
                return;
index 9fd188f..dcb33d2 100644 (file)
@@ -3354,7 +3354,7 @@ static int _hid_get_report(struct hid_device_priv *dev, HANDLE hid_handle, int i
                usbi_dbg("program assertion failed: hid_buffer is not NULL");
 
        if ((*size == 0) || (*size > MAX_HID_REPORT_SIZE)) {
-               usbi_dbg("invalid size (%zu)", *size);
+               usbi_dbg("invalid size ("PRIuPTR")", (uintptr_t)*size);
                return LIBUSB_ERROR_INVALID_PARAM;
        }
 
@@ -3433,7 +3433,7 @@ static int _hid_set_report(struct hid_device_priv *dev, HANDLE hid_handle, int i
                usbi_dbg("program assertion failed: hid_buffer is not NULL");
 
        if ((*size == 0) || (*size > max_report_size)) {
-               usbi_dbg("invalid size (%zu)", *size);
+               usbi_dbg("invalid size ("PRIuPTR")", (uintptr_t)*size);
                return LIBUSB_ERROR_INVALID_PARAM;
        }
 
@@ -3633,7 +3633,7 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
                size[1] = capabilities.NumberOutputValueCaps;
                size[2] = capabilities.NumberFeatureValueCaps;
                for (j = HidP_Input; j <= HidP_Feature; j++) {
-                       usbi_dbg("%u HID %s report value(s) found", (unsigned int)size[j], type[j]);
+                       usbi_dbg("%lu HID %s report value(s) found", size[j], type[j]);
                        priv->hid->uses_report_ids[j] = false;
                        if (size[j] > 0) {
                                value_caps = calloc(size[j], sizeof(HIDP_VALUE_CAPS));
index a8f90d9..b05b0f4 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11433
+#define LIBUSB_NANO 11434