diff options
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/mem_pool/mem_pool.cpp | 6 | ||||
-rw-r--r-- | src/lib/utils/socket/socket.cpp | 11 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/utils/mem_pool/mem_pool.cpp b/src/lib/utils/mem_pool/mem_pool.cpp index 9542ecbfa..25a3fb408 100644 --- a/src/lib/utils/mem_pool/mem_pool.cpp +++ b/src/lib/utils/mem_pool/mem_pool.cpp @@ -149,7 +149,7 @@ class BitMap final BitMap(size_t bits) : m_len(bits) { m_bits.resize((bits + BITMASK_BITS - 1) / BITMASK_BITS); - m_main_mask = ~static_cast<bitmask_type>(0); + m_main_mask = static_cast<bitmask_type>(0) - 1; // all bits set m_last_mask = m_main_mask; if(bits % BITMASK_BITS != 0) @@ -163,7 +163,7 @@ class BitMap final BOTAN_ASSERT_NOMSG(bit <= m_len); const size_t w = bit / BITMASK_BITS; BOTAN_ASSERT_NOMSG(w < m_bits.size()); - const size_t mask = static_cast<bitmask_type>(1) << (bit % BITMASK_BITS); + const bitmask_type mask = static_cast<bitmask_type>(1) << (bit % BITMASK_BITS); m_bits[w] = m_bits[w] & (~mask); } @@ -203,7 +203,7 @@ bool BitMap::find_free(size_t* bit) if((m_bits[i] & mask) != mask) { size_t free_bit = find_set_bit(~m_bits[i]); - const size_t bmask = static_cast<bitmask_type>(1) << (free_bit % BITMASK_BITS); + const bitmask_type bmask = static_cast<bitmask_type>(1) << (free_bit % BITMASK_BITS); BOTAN_ASSERT_NOMSG((m_bits[i] & bmask) == 0); m_bits[i] |= bmask; *bit = BITMASK_BITS*i + free_bit; 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; } |