aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/socket/socket.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-06-29 16:16:21 -0400
committerJack Lloyd <[email protected]>2019-06-29 17:11:19 -0400
commit8b8745236368c70a82db2b19feeed5e9f9b59c5b (patch)
tree1495a04a7e6f117e2cacd69ff0f7b2c4a31ddee9 /src/lib/utils/socket/socket.cpp
parent5922b1c3abf00c0e22e86498e1ee3a51e5343b0f (diff)
Fix various MSVC warnings
Diffstat (limited to 'src/lib/utils/socket/socket.cpp')
-rw-r--r--src/lib/utils/socket/socket.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/utils/socket/socket.cpp b/src/lib/utils/socket/socket.cpp
index e7c2ccd81..41177809e 100644
--- a/src/lib/utils/socket/socket.cpp
+++ b/src/lib/utils/socket/socket.cpp
@@ -144,6 +144,7 @@ class BSD_Socket final : public OS::Socket
#if defined(BOTAN_TARGET_OS_HAS_WINSOCK2)
typedef SOCKET socket_type;
typedef int socket_op_ret_type;
+ typedef int socklen_type;
static socket_type invalid_socket() { return INVALID_SOCKET; }
static void close_socket(socket_type s) { ::closesocket(s); }
static std::string get_last_socket_error() { return std::to_string(::WSAGetLastError()); }
@@ -183,6 +184,7 @@ class BSD_Socket final : public OS::Socket
#else
typedef int socket_type;
typedef ssize_t socket_op_ret_type;
+ typedef socklen_t socklen_type;
static socket_type invalid_socket() { return -1; }
static void close_socket(socket_type s) { ::close(s); }
static std::string get_last_socket_error() { return ::strerror(errno); }
@@ -234,7 +236,7 @@ class BSD_Socket final : public OS::Socket
set_nonblocking(m_socket);
- int err = ::connect(m_socket, rp->ai_addr, rp->ai_addrlen);
+ int err = ::connect(m_socket, rp->ai_addr, static_cast<socklen_type>(rp->ai_addrlen));
if(err == -1)
{
@@ -244,7 +246,8 @@ class BSD_Socket final : public OS::Socket
struct timeval timeout_tv = make_timeout_tv();
fd_set write_set;
FD_ZERO(&write_set);
- FD_SET(m_socket, &write_set);
+ // Weirdly, Winsock uses a SOCKET type but wants FD_SET to get an int instead
+ FD_SET(static_cast<int>(m_socket), &write_set);
active = ::select(m_socket + 1, nullptr, &write_set, nullptr, &timeout_tv);
@@ -336,8 +339,8 @@ class BSD_Socket final : public OS::Socket
struct timeval make_timeout_tv() const
{
struct timeval tv;
- tv.tv_sec = m_timeout.count() / 1000000;
- tv.tv_usec = m_timeout.count() % 1000000;
+ tv.tv_sec = static_cast<time_t>(m_timeout.count() / 1000000);
+ tv.tv_usec = static_cast<long>(m_timeout.count() % 1000000);;
return tv;
}