summaryrefslogtreecommitdiff
path: root/libusb/os/poll_windows.c
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-01-26 14:31:35 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2020-01-26 14:31:35 -0800
commit80d2238cb80469aee03d0367080350496d8548eb (patch)
treeefd84ff3c454b0e437b773bc3248a248d9e5fb2c /libusb/os/poll_windows.c
parenta96937af9935c569b679d8ada2f59e90754b700a (diff)
downloadlibusb-80d2238cb80469aee03d0367080350496d8548eb.tar.gz
Windows: Fix GCC printf format warnings due to DWORD/ULONG types
The Visual Studio compiler considers a long to always be 32-bits, so the official Windows API headers define the DWORD and ULONG types as unsigned long proper. GCC (and possibly other compilers) vary the width of a long to match the build target, so this complicates printf format strings for these two types because the underlying type is inconsistent. Address this mess by introducing a macro that casts as necessary for the compiler. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/os/poll_windows.c')
-rw-r--r--libusb/os/poll_windows.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c
index afcc233..830c7e5 100644
--- a/libusb/os/poll_windows.c
+++ b/libusb/os/poll_windows.c
@@ -36,6 +36,7 @@
*/
#include "libusbi.h"
+#include "windows_common.h"
#include <errno.h>
#include <intrin.h>
@@ -133,14 +134,14 @@ static int install_fd(struct file_descriptor *fd)
for (n = 0; n < fd_table_size; n += BITMAP_BITS_PER_WORD) {
unsigned int idx = n / BITMAP_BITS_PER_WORD;
- unsigned long mask, pos = 0UL;
+ ULONG mask, pos = 0U;
mask = ~fd_table_bitmap[idx];
- if (mask == 0UL)
+ if (mask == 0U)
continue;
assert(_BitScanForward(&pos, mask));
- fd_table_bitmap[idx] |= 1UL << pos;
+ fd_table_bitmap[idx] |= 1U << pos;
n += pos;
break;
}
@@ -157,7 +158,7 @@ static void remove_fd(unsigned int pos)
{
assert(fd_table[pos] != NULL);
fd_table[pos] = NULL;
- fd_table_bitmap[pos / BITMAP_BITS_PER_WORD] &= ~(1UL << (pos % BITMAP_BITS_PER_WORD));
+ fd_table_bitmap[pos / BITMAP_BITS_PER_WORD] &= ~(1U << (pos % BITMAP_BITS_PER_WORD));
fd_count--;
if (fd_count == 0) {
free(fd_table);
@@ -307,11 +308,11 @@ static DWORD poll_wait(const HANDLE *wait_handles, DWORD num_wait_handles, DWORD
for (n = 0; n < num_threads; n++) {
if (thread_data[n].thread != NULL) {
if (WaitForSingleObject(thread_data[n].thread, INFINITE) != WAIT_OBJECT_0)
- usbi_err(NULL, "WaitForSingleObject() failed: %lu", GetLastError());
+ usbi_err(NULL, "WaitForSingleObject() failed: %lu", ULONG_CAST(GetLastError()));
CloseHandle(thread_data[n].thread);
}
if (thread_data[n].error) {
- usbi_err(NULL, "wait thread %d had error %lu\n", n, thread_data[n].error);
+ usbi_err(NULL, "wait thread %d had error %lu\n", n, ULONG_CAST(thread_data[n].error));
error = thread_data[n].error;
status = WAIT_FAILED;
}
@@ -407,7 +408,7 @@ int usbi_poll(struct pollfd *fds, usbi_nfds_t nfds, int timeout)
assert(timeout > 0);
timeout = 0;
} else if (ret == WAIT_FAILED) {
- usbi_err(NULL, "WaitForMultipleObjects failed: %lu", GetLastError());
+ usbi_err(NULL, "WaitForMultipleObjects failed: %lu", ULONG_CAST(GetLastError()));
errno = EIO;
nready = -1;
}