src,test: squelch clang signed/unsigned conversion warnings
This commit is contained in:
parent
042bfd32f3
commit
8f4d4e9602
21
src/port.c
21
src/port.c
@ -145,9 +145,9 @@ static void _ep_port_update_events_if_polling(ep_port_t* port_info) {
|
||||
static int _ep_port_feed_events(ep_port_t* port_info,
|
||||
struct epoll_event* epoll_events,
|
||||
OVERLAPPED_ENTRY* iocp_events,
|
||||
int iocp_event_count) {
|
||||
DWORD iocp_event_count) {
|
||||
int epoll_event_count = 0;
|
||||
int i;
|
||||
DWORD i;
|
||||
|
||||
for (i = 0; i < iocp_event_count; i++) {
|
||||
OVERLAPPED* overlapped = iocp_events[i].lpOverlapped;
|
||||
@ -162,9 +162,9 @@ static int _ep_port_feed_events(ep_port_t* port_info,
|
||||
static int _ep_port_poll(ep_port_t* port_info,
|
||||
struct epoll_event* epoll_events,
|
||||
OVERLAPPED_ENTRY* iocp_events,
|
||||
int maxevents,
|
||||
DWORD maxevents,
|
||||
DWORD timeout) {
|
||||
ULONG completion_count;
|
||||
DWORD completion_count;
|
||||
|
||||
if (_ep_port_update_events(port_info) < 0)
|
||||
return -1;
|
||||
@ -197,7 +197,7 @@ int ep_port_wait(ep_port_t* port_info,
|
||||
int timeout) {
|
||||
OVERLAPPED_ENTRY stack_iocp_events[_PORT_MAX_ON_STACK_COMPLETIONS];
|
||||
OVERLAPPED_ENTRY* iocp_events;
|
||||
ULONGLONG due = 0;
|
||||
uint64_t due = 0;
|
||||
DWORD gqcs_timeout;
|
||||
int result;
|
||||
|
||||
@ -209,7 +209,8 @@ int ep_port_wait(ep_port_t* port_info,
|
||||
* memory for it on the heap. */
|
||||
if ((size_t) maxevents <= array_count(stack_iocp_events)) {
|
||||
iocp_events = stack_iocp_events;
|
||||
} else if ((iocp_events = malloc(maxevents * sizeof *iocp_events)) == NULL) {
|
||||
} else if ((iocp_events =
|
||||
malloc((size_t) maxevents * sizeof *iocp_events)) == NULL) {
|
||||
iocp_events = stack_iocp_events;
|
||||
maxevents = array_count(stack_iocp_events);
|
||||
}
|
||||
@ -217,7 +218,7 @@ int ep_port_wait(ep_port_t* port_info,
|
||||
/* Compute the timeout for GetQueuedCompletionStatus, and the wait end
|
||||
* time, if the user specified a timeout other than zero or infinite. */
|
||||
if (timeout > 0) {
|
||||
due = GetTickCount64() + timeout;
|
||||
due = GetTickCount64() + (uint64_t) timeout;
|
||||
gqcs_timeout = (DWORD) timeout;
|
||||
} else if (timeout == 0) {
|
||||
gqcs_timeout = 0;
|
||||
@ -230,10 +231,10 @@ int ep_port_wait(ep_port_t* port_info,
|
||||
/* Dequeue completion packets until either at least one interesting event
|
||||
* has been discovered, or the timeout is reached. */
|
||||
for (;;) {
|
||||
ULONGLONG now;
|
||||
uint64_t now;
|
||||
|
||||
result =
|
||||
_ep_port_poll(port_info, events, iocp_events, maxevents, gqcs_timeout);
|
||||
result = _ep_port_poll(
|
||||
port_info, events, iocp_events, (DWORD) maxevents, gqcs_timeout);
|
||||
if (result < 0 || result > 0)
|
||||
break; /* Result, error, or time-out. */
|
||||
|
||||
|
||||
@ -45,13 +45,13 @@ static void _await_event(void* address) {
|
||||
static inline uint32_t _sync_add_and_fetch(volatile uint32_t* target,
|
||||
uint32_t value) {
|
||||
static_assert(sizeof(*target) == sizeof(long), "");
|
||||
return InterlockedAdd((volatile long*) target, value);
|
||||
return (uint32_t) InterlockedAdd((volatile long*) target, (long) value);
|
||||
}
|
||||
|
||||
static inline uint32_t _sync_fetch_and_set(volatile uint32_t* target,
|
||||
uint32_t value) {
|
||||
static_assert(sizeof(*target) == sizeof(long), "");
|
||||
return InterlockedExchange((volatile long*) target, value);
|
||||
return (uint32_t) InterlockedExchange((volatile long*) target, (long) value);
|
||||
}
|
||||
|
||||
void reflock_ref(reflock_t* reflock) {
|
||||
@ -61,7 +61,7 @@ void reflock_ref(reflock_t* reflock) {
|
||||
}
|
||||
|
||||
void reflock_unref(reflock_t* reflock) {
|
||||
uint32_t state = _sync_add_and_fetch(&reflock->state, -(int32_t) _REF);
|
||||
uint32_t state = _sync_add_and_fetch(&reflock->state, 0 - _REF);
|
||||
uint32_t ref_count = state & _REF_MASK;
|
||||
uint32_t destroy = state & _DESTROY_MASK;
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ int ep_sock_set_event(ep_port_t* port_info,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline ULONG _epoll_events_to_afd_events(uint32_t epoll_events) {
|
||||
static inline DWORD _epoll_events_to_afd_events(uint32_t epoll_events) {
|
||||
/* Always monitor for AFD_POLL_LOCAL_CLOSE, which is triggered when the
|
||||
* socket is closed with closesocket() or CloseHandle(). */
|
||||
DWORD afd_events = AFD_POLL_LOCAL_CLOSE;
|
||||
@ -178,7 +178,7 @@ static inline ULONG _epoll_events_to_afd_events(uint32_t epoll_events) {
|
||||
return afd_events;
|
||||
}
|
||||
|
||||
static inline uint32_t _afd_events_to_epoll_events(ULONG afd_events) {
|
||||
static inline uint32_t _afd_events_to_epoll_events(DWORD afd_events) {
|
||||
uint32_t epoll_events = 0;
|
||||
|
||||
if (afd_events & (AFD_POLL_RECEIVE | AFD_POLL_ACCEPT))
|
||||
|
||||
4
src/ws.c
4
src/ws.c
@ -18,7 +18,7 @@ int ws_global_init(void) {
|
||||
|
||||
r = WSAStartup(MAKEWORD(2, 2), &wsa_data);
|
||||
if (r != 0)
|
||||
return_set_error(-1, r);
|
||||
return_set_error(-1, (DWORD) r);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -64,7 +64,7 @@ int ws_get_protocol_catalog(WSAPROTOCOL_INFOW** infos_out,
|
||||
}
|
||||
|
||||
*infos_out = infos;
|
||||
*infos_count_out = count;
|
||||
*infos_count_out = (size_t) count;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#include "wepoll.h"
|
||||
#include "win.h"
|
||||
|
||||
static SOCKET create_and_add_socket(HANDLE ephnd, int events) {
|
||||
static SOCKET create_and_add_socket(HANDLE ephnd, uint32_t events) {
|
||||
SOCKET sock;
|
||||
struct epoll_event ev;
|
||||
int r;
|
||||
|
||||
@ -15,15 +15,14 @@
|
||||
|
||||
static SOCKET create_and_add_socket(HANDLE epfd) {
|
||||
SOCKET sock;
|
||||
unsigned long one;
|
||||
unsigned long one = 1;
|
||||
int r;
|
||||
struct epoll_event ev;
|
||||
|
||||
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
check(sock > 0);
|
||||
|
||||
one = 1;
|
||||
r = ioctlsocket(sock, FIONBIO, &one);
|
||||
r = ioctlsocket(sock, (long) FIONBIO, &one);
|
||||
check(r == 0);
|
||||
|
||||
ev.events = 0;
|
||||
@ -73,7 +72,7 @@ int main(void) {
|
||||
do {
|
||||
r = epoll_wait(epfd, ev_out, array_count(ev_out), count > 0 ? 0 : -1);
|
||||
check(r >= 0);
|
||||
count += r;
|
||||
count += (uint64_t) r;
|
||||
} while (r > 0);
|
||||
|
||||
total_events += count;
|
||||
|
||||
@ -18,7 +18,7 @@ static void create_and_add_socket(HANDLE epoll_hnd,
|
||||
sock = socket(af, type, protocol);
|
||||
check(sock != INVALID_SOCKET);
|
||||
|
||||
r = ioctlsocket(sock, FIONBIO, &one);
|
||||
r = ioctlsocket(sock, (long) FIONBIO, &one);
|
||||
check(r == 0);
|
||||
|
||||
ev.events = EPOLLOUT | EPOLLONESHOT;
|
||||
|
||||
@ -25,7 +25,7 @@ typedef struct test_context {
|
||||
static SOCKET create_socket(unsigned short port) {
|
||||
SOCKET sock;
|
||||
struct sockaddr_in address;
|
||||
unsigned long one;
|
||||
unsigned long one = 1;
|
||||
int r;
|
||||
|
||||
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
@ -37,8 +37,7 @@ static SOCKET create_socket(unsigned short port) {
|
||||
r = bind(sock, (struct sockaddr*) &address, sizeof address);
|
||||
check(r == 0);
|
||||
|
||||
one = 1;
|
||||
r = ioctlsocket(sock, FIONBIO, &one);
|
||||
r = ioctlsocket(sock, (long) FIONBIO, &one);
|
||||
check(r == 0);
|
||||
|
||||
return sock;
|
||||
@ -114,7 +113,7 @@ int main(void) {
|
||||
|
||||
/* Register recv_sock with the epoll port. */
|
||||
ev.events = EPOLLIN;
|
||||
ev.data.u64 = rand();
|
||||
ev.data.u64 = (uint64_t) rand();
|
||||
r = epoll_ctl(port, EPOLL_CTL_ADD, recv_sock, &ev);
|
||||
check(r == 0);
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ err1:
|
||||
|
||||
static int sock_set_nonblock(SOCKET sock, bool enable) {
|
||||
u_long arg = enable;
|
||||
return ioctlsocket(sock, FIONBIO, &arg);
|
||||
return ioctlsocket(sock, (long) FIONBIO, &arg);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
||||
@ -54,7 +54,7 @@ static void check_tree_count(const tree_t* tree, size_t expected_count) {
|
||||
}
|
||||
|
||||
static void keys_increasing(tree_t* tree, test_op_t op) {
|
||||
ssize_t i;
|
||||
size_t i;
|
||||
for (i = 0; i < NODE_COUNT; i++)
|
||||
op(tree, i);
|
||||
}
|
||||
@ -62,7 +62,7 @@ static void keys_increasing(tree_t* tree, test_op_t op) {
|
||||
static void keys_decreasing(tree_t* tree, test_op_t op) {
|
||||
ssize_t i;
|
||||
for (i = NODE_COUNT - 1; i >= 0; i--)
|
||||
op(tree, i);
|
||||
op(tree, (size_t) i);
|
||||
}
|
||||
|
||||
static void keys_random(tree_t* tree, test_op_t op) {
|
||||
@ -74,7 +74,7 @@ static void keys_random(tree_t* tree, test_op_t op) {
|
||||
keys[index] = index;
|
||||
|
||||
for (left = NODE_COUNT - 1; left >= 0; left--) {
|
||||
index = left > 0 ? rand() % left : 0;
|
||||
index = left == 0 ? 0 : (uintptr_t)(rand() % left);
|
||||
key = keys[index];
|
||||
keys[index] = keys[left];
|
||||
op(tree, key);
|
||||
|
||||
@ -27,7 +27,7 @@ int main(void) {
|
||||
check(epoll_hnd != NULL);
|
||||
|
||||
srv = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
r = ioctlsocket(srv, FIONBIO, &one);
|
||||
r = ioctlsocket(srv, (long) FIONBIO, &one);
|
||||
check(r == 0);
|
||||
|
||||
address.sin_family = AF_INET;
|
||||
@ -44,7 +44,7 @@ int main(void) {
|
||||
for (i = 0; i < NUM_PINGERS; i++) {
|
||||
SOCKET sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
|
||||
r = ioctlsocket(sock, FIONBIO, &one);
|
||||
r = ioctlsocket(sock, (long) FIONBIO, &one);
|
||||
check(r == 0);
|
||||
|
||||
r = setsockopt(
|
||||
@ -88,7 +88,7 @@ int main(void) {
|
||||
check(count >= 0);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
int revents = events[i].events;
|
||||
uint32_t revents = events[i].events;
|
||||
|
||||
if (revents & EPOLLERR) {
|
||||
SOCKET sock = events[i].data.sock;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user