medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f6ca9e905d134211fb5648b208bf1529318898b3
parent 00c01fae41f6f46fe112f93fa198ceaca9de0c7e
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Jan 22 14:08:12 +0200

MSVC warnings

Diffstat:
platform_network.h | 8++++++--
win32_network.h | 2+-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/platform_network.h b/platform_network.h @@ -8,8 +8,12 @@ enum TransportProtocol { NET_UDP, NET_TCP }; enum IPvX { NET_IPV4, NET_IPV6 }; enum NonblockingBool { NET_BLOCKING, NET_NONBLOCKING }; +#if PLATFORM_UNIX +typedef int SOCKET; +#endif + struct Socket { - int fd; + SOCKET fd; TransportProtocol transport; IPvX ipvx; }; @@ -62,7 +66,7 @@ inline void sock_init( Socket * sock, IPvX ipvx, TransportProtocol transport, No inline void sock_send_udp( Socket sock, const char * data, size_t len, const sockaddr_in & addr ) { ASSERT( sock.transport == NET_UDP ); - ssize_t ok = sendto( sock.fd, data, len, 0, ( sockaddr * ) &addr, sizeof( addr ) ); + ssize_t ok = sendto( sock.fd, data, checked_cast< int >( len ), 0, ( sockaddr * ) &addr, sizeof( addr ) ); if( ok == SOCKET_ERROR ) { FATAL( "sendto" ); } diff --git a/win32_network.h b/win32_network.h @@ -31,7 +31,7 @@ inline void sock_fd_nonblocking( int fd ) { inline bool sock_tryrecv_udp( Socket sock, char * buf, size_t len, sockaddr_storage * addr, socklen_t * addr_len, size_t * bytes_received ) { ASSERT( sock.transport == NET_UDP ); - int received = recvfrom( sock.fd, buf, len, 0, ( sockaddr * ) addr, addr_len ); + int received = recvfrom( sock.fd, buf, checked_cast< int >( len ), 0, ( sockaddr * ) addr, addr_len ); if( received == SOCKET_ERROR ) { int error = WSAGetLastError(); if( error == WSAEWOULDBLOCK || error == WSAECONNRESET ) {