ws: add out param for catalog entry count to ws_get_protocol_catalog()

This avoids a sign-conversion warning on clang 6.x.
This commit is contained in:
Bert Belder 2018-05-16 21:17:17 -07:00
parent fa16c36d95
commit a60d90a26a
No known key found for this signature in database
GPG Key ID: 7A77887B2E2ED461
4 changed files with 11 additions and 9 deletions

View File

@ -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

View File

@ -26,9 +26,9 @@
#pragma warning(push, 1)
#endif
#include <Windows.h>
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <WinSock2.h>
#include <Windows.h>
#ifndef __GNUC__
#pragma warning(pop)

View File

@ -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;
}
}

View File

@ -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_ */