From 944fdd173f40c0fcc718d6aa2af191bf993adc70 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Nov 2016 19:00:01 +0000 Subject: Warnings fixes --- src/OSSupport/UDPEndpointImpl.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/OSSupport') diff --git a/src/OSSupport/UDPEndpointImpl.cpp b/src/OSSupport/UDPEndpointImpl.cpp index 68117e5a0..e43e739b4 100644 --- a/src/OSSupport/UDPEndpointImpl.cpp +++ b/src/OSSupport/UDPEndpointImpl.cpp @@ -134,20 +134,20 @@ protected: { if (m_HasIPv6) { - sendto(m_MainSock, m_Data.data(), static_cast(m_Data.size()), 0, reinterpret_cast(&m_AddrIPv6), static_cast(sizeof(m_AddrIPv6))); + sendto(m_MainSock, m_Data.data(), m_Data.size(), 0, reinterpret_cast(&m_AddrIPv6), static_cast(sizeof(m_AddrIPv6))); } else if (m_HasIPv4) { // If the secondary socket is valid, it is an IPv4 socket, so use that: if (m_SecondSock != -1) { - sendto(m_SecondSock, m_Data.data(), static_cast(m_Data.size()), 0, reinterpret_cast(&m_AddrIPv4), static_cast(sizeof(m_AddrIPv4))); + sendto(m_SecondSock, m_Data.data(), m_Data.size(), 0, reinterpret_cast(&m_AddrIPv4), static_cast(sizeof(m_AddrIPv4))); } else { // Need an address conversion from IPv4 to IPv6-mapped-IPv4: ConvertIPv4ToMappedIPv6(m_AddrIPv4, m_AddrIPv6); - sendto(m_MainSock, m_Data.data(), static_cast(m_Data.size()), 0, reinterpret_cast(&m_AddrIPv6), static_cast(sizeof(m_AddrIPv6))); + sendto(m_MainSock, m_Data.data(), m_Data.size(), 0, reinterpret_cast(&m_AddrIPv6), static_cast(sizeof(m_AddrIPv6))); } } else @@ -164,7 +164,7 @@ protected: LOGD("UDP endpoint queued sendto: Name not resolved to IPv4 for an IPv4-only socket"); return; } - sendto(m_MainSock, m_Data.data(), static_cast(m_Data.size()), 0, reinterpret_cast(&m_AddrIPv4), static_cast(sizeof(m_AddrIPv4))); + sendto(m_MainSock, m_Data.data(), m_Data.size(), 0, reinterpret_cast(&m_AddrIPv4), static_cast(sizeof(m_AddrIPv4))); } } @@ -284,19 +284,19 @@ bool cUDPEndpointImpl::Send(const AString & a_Payload, const AString & a_Host, U if (IsValidSocket(m_SecondarySock)) { // The secondary socket, which is always IPv4, is present: - NumSent = static_cast(sendto(m_SecondarySock, a_Payload.data(), static_cast(a_Payload.size()), 0, reinterpret_cast(&sa), static_cast(salen))); + NumSent = static_cast(sendto(m_SecondarySock, a_Payload.data(), a_Payload.size(), 0, reinterpret_cast(&sa), static_cast(salen))); } else { // Need to convert IPv4 to IPv6 address before sending: sockaddr_in6 IPv6; ConvertIPv4ToMappedIPv6(*reinterpret_cast(&sa), IPv6); - NumSent = static_cast(sendto(m_MainSock, a_Payload.data(), static_cast(a_Payload.size()), 0, reinterpret_cast(&IPv6), static_cast(sizeof(IPv6)))); + NumSent = static_cast(sendto(m_MainSock, a_Payload.data(), a_Payload.size(), 0, reinterpret_cast(&IPv6), static_cast(sizeof(IPv6)))); } } else { - NumSent = static_cast(sendto(m_MainSock, a_Payload.data(), static_cast(a_Payload.size()), 0, reinterpret_cast(&sa), static_cast(salen))); + NumSent = static_cast(sendto(m_MainSock, a_Payload.data(), a_Payload.size(), 0, reinterpret_cast(&sa), static_cast(salen))); } break; } @@ -304,7 +304,7 @@ bool cUDPEndpointImpl::Send(const AString & a_Payload, const AString & a_Host, U case AF_INET6: { reinterpret_cast(&sa)->sin6_port = htons(a_Port); - NumSent = static_cast(sendto(m_MainSock, a_Payload.data(), static_cast(a_Payload.size()), 0, reinterpret_cast(&sa), static_cast(salen))); + NumSent = static_cast(sendto(m_MainSock, a_Payload.data(), a_Payload.size(), 0, reinterpret_cast(&sa), static_cast(salen))); break; } default: @@ -563,10 +563,9 @@ void cUDPEndpointImpl::Callback(evutil_socket_t a_Socket, short a_What) { // Receive datagram from the socket: char buf[64 KiB]; - socklen_t buflen = static_cast(sizeof(buf)); sockaddr_storage sa; socklen_t salen = static_cast(sizeof(sa)); - auto len = recvfrom(a_Socket, buf, buflen, 0, reinterpret_cast(&sa), &salen); + auto len = recvfrom(a_Socket, buf, sizeof(buf), 0, reinterpret_cast(&sa), &salen); if (len >= 0) { // Convert the remote IP address to a string: -- cgit v1.2.3