From a60d90a26ad96b85a1c820e06d7ea0114e33766f Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 16 May 2018 21:17:17 -0700 Subject: [PATCH] ws: add out param for catalog entry count to ws_get_protocol_catalog() This avoids a sign-conversion warning on clang 6.x. --- src/afd.c | 7 +++---- src/win.h | 4 ++-- src/ws.c | 6 ++++-- src/ws.h | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/afd.c b/src/afd.c index 8c32333..67143d2 100644 --- a/src/afd.c +++ b/src/afd.c @@ -65,13 +65,12 @@ static const WSAPROTOCOL_INFOW* _afd_find_protocol_info( int afd_global_init(void) { WSAPROTOCOL_INFOW* infos; - ssize_t infos_count; + size_t infos_count; const WSAPROTOCOL_INFOW* afd_info; /* Load the winsock catalog. */ - infos_count = ws_get_protocol_catalog(&infos); - if (infos_count < 0) - return_map_error(-1); + if (ws_get_protocol_catalog(&infos, &infos_count) < 0) + return -1; /* Find a WSAPROTOCOL_INFOW structure that we can use to create an MSAFD * socket. Preferentially we pick a UDP socket, otherwise try TCP or any diff --git a/src/win.h b/src/win.h index a31654e..f42bb45 100644 --- a/src/win.h +++ b/src/win.h @@ -26,9 +26,9 @@ #pragma warning(push, 1) #endif -#include -#include #include +#include +#include #ifndef __GNUC__ #pragma warning(pop) diff --git a/src/ws.c b/src/ws.c index 73aa86a..c818310 100644 --- a/src/ws.c +++ b/src/ws.c @@ -43,7 +43,8 @@ SOCKET ws_get_base_socket(SOCKET socket) { /* Retrieves a copy of the winsock catalog. * The infos pointer must be released by the caller with free(). */ -ssize_t ws_get_protocol_catalog(WSAPROTOCOL_INFOW** infos_out) { +int ws_get_protocol_catalog(WSAPROTOCOL_INFOW** infos_out, + size_t* infos_count_out) { DWORD buffer_size = _WS_INITIAL_CATALOG_BUFFER_SIZE; int count; WSAPROTOCOL_INFOW* infos; @@ -63,6 +64,7 @@ ssize_t ws_get_protocol_catalog(WSAPROTOCOL_INFOW** infos_out) { } *infos_out = infos; - return count; + *infos_count_out = count; + return 0; } } diff --git a/src/ws.h b/src/ws.h index 7ab527a..f2dd66e 100644 --- a/src/ws.h +++ b/src/ws.h @@ -8,6 +8,7 @@ WEPOLL_INTERNAL int ws_global_init(void); WEPOLL_INTERNAL SOCKET ws_get_base_socket(SOCKET socket); -WEPOLL_INTERNAL ssize_t ws_get_protocol_catalog(WSAPROTOCOL_INFOW** infos_out); +WEPOLL_INTERNAL int ws_get_protocol_catalog(WSAPROTOCOL_INFOW** infos_out, + size_t* infos_count_out); #endif /* WEPOLL_WS_H_ */