diff options
author | Mat <mail@mathias.is> | 2020-05-10 18:18:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-10 18:18:28 +0200 |
commit | e053f72db824a16c1cb59107315001473058e2bc (patch) | |
tree | c54dafbc0048939697cb6ec7a8034534738bdbed /src/OSSupport | |
parent | Cleanup some workarounds and warnings (#4735) (diff) | |
download | cuberite-e053f72db824a16c1cb59107315001473058e2bc.tar cuberite-e053f72db824a16c1cb59107315001473058e2bc.tar.gz cuberite-e053f72db824a16c1cb59107315001473058e2bc.tar.bz2 cuberite-e053f72db824a16c1cb59107315001473058e2bc.tar.lz cuberite-e053f72db824a16c1cb59107315001473058e2bc.tar.xz cuberite-e053f72db824a16c1cb59107315001473058e2bc.tar.zst cuberite-e053f72db824a16c1cb59107315001473058e2bc.zip |
Diffstat (limited to 'src/OSSupport')
-rw-r--r-- | src/OSSupport/StackTrace.cpp | 4 | ||||
-rw-r--r-- | src/OSSupport/UDPEndpointImpl.cpp | 19 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/OSSupport/StackTrace.cpp b/src/OSSupport/StackTrace.cpp index b8f80f5f3..d252e1e83 100644 --- a/src/OSSupport/StackTrace.cpp +++ b/src/OSSupport/StackTrace.cpp @@ -7,7 +7,7 @@ #include "StackTrace.h" #ifdef _WIN32 #include "WinStackWalker.h" -#elif !defined(ANDROID) // The Android NDK has no execinfo header +#else #ifdef __GLIBC__ #include <execinfo.h> #endif @@ -30,7 +30,7 @@ void PrintStackTrace(void) } } sw; sw.ShowCallstack(); - #elif !defined(ANDROID) + #else #ifdef __GLIBC__ // Use the backtrace() function to get and output the stackTrace: // Code adapted from https://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes diff --git a/src/OSSupport/UDPEndpointImpl.cpp b/src/OSSupport/UDPEndpointImpl.cpp index 3235ff91f..5984bc4e2 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<socklen_t>(m_Data.size()), 0, reinterpret_cast<const sockaddr *>(&m_AddrIPv6), static_cast<socklen_t>(sizeof(m_AddrIPv6))); + sendto(m_MainSock, m_Data.data(), m_Data.size(), 0, reinterpret_cast<const sockaddr *>(&m_AddrIPv6), static_cast<socklen_t>(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<socklen_t>(m_Data.size()), 0, reinterpret_cast<const sockaddr *>(&m_AddrIPv4), static_cast<socklen_t>(sizeof(m_AddrIPv4))); + sendto(m_SecondSock, m_Data.data(), m_Data.size(), 0, reinterpret_cast<const sockaddr *>(&m_AddrIPv4), static_cast<socklen_t>(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<socklen_t>(m_Data.size()), 0, reinterpret_cast<const sockaddr *>(&m_AddrIPv6), static_cast<socklen_t>(sizeof(m_AddrIPv6))); + sendto(m_MainSock, m_Data.data(), m_Data.size(), 0, reinterpret_cast<const sockaddr *>(&m_AddrIPv6), static_cast<socklen_t>(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<socklen_t>(m_Data.size()), 0, reinterpret_cast<const sockaddr *>(&m_AddrIPv4), static_cast<socklen_t>(sizeof(m_AddrIPv4))); + sendto(m_MainSock, m_Data.data(), m_Data.size(), 0, reinterpret_cast<const sockaddr *>(&m_AddrIPv4), static_cast<socklen_t>(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<int>(sendto(m_SecondarySock, a_Payload.data(), static_cast<socklen_t>(a_Payload.size()), 0, reinterpret_cast<const sockaddr *>(&sa), static_cast<socklen_t>(salen))); + NumSent = static_cast<int>(sendto(m_SecondarySock, a_Payload.data(), a_Payload.size(), 0, reinterpret_cast<const sockaddr *>(&sa), static_cast<socklen_t>(salen))); } else { // Need to convert IPv4 to IPv6 address before sending: sockaddr_in6 IPv6; ConvertIPv4ToMappedIPv6(*reinterpret_cast<sockaddr_in *>(&sa), IPv6); - NumSent = static_cast<int>(sendto(m_MainSock, a_Payload.data(), static_cast<socklen_t>(a_Payload.size()), 0, reinterpret_cast<const sockaddr *>(&IPv6), static_cast<socklen_t>(sizeof(IPv6)))); + NumSent = static_cast<int>(sendto(m_MainSock, a_Payload.data(), a_Payload.size(), 0, reinterpret_cast<const sockaddr *>(&IPv6), static_cast<socklen_t>(sizeof(IPv6)))); } } else { - NumSent = static_cast<int>(sendto(m_MainSock, a_Payload.data(), static_cast<socklen_t>(a_Payload.size()), 0, reinterpret_cast<const sockaddr *>(&sa), static_cast<socklen_t>(salen))); + NumSent = static_cast<int>(sendto(m_MainSock, a_Payload.data(), a_Payload.size(), 0, reinterpret_cast<const sockaddr *>(&sa), static_cast<socklen_t>(salen))); } break; } @@ -304,7 +304,7 @@ bool cUDPEndpointImpl::Send(const AString & a_Payload, const AString & a_Host, U case AF_INET6: { reinterpret_cast<sockaddr_in6 *>(&sa)->sin6_port = htons(a_Port); - NumSent = static_cast<int>(sendto(m_MainSock, a_Payload.data(), static_cast<socklen_t>(a_Payload.size()), 0, reinterpret_cast<const sockaddr *>(&sa), static_cast<socklen_t>(salen))); + NumSent = static_cast<int>(sendto(m_MainSock, a_Payload.data(), a_Payload.size(), 0, reinterpret_cast<const sockaddr *>(&sa), static_cast<socklen_t>(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<socklen_t>(sizeof(buf)); sockaddr_storage sa; socklen_t salen = static_cast<socklen_t>(sizeof(sa)); - auto len = recvfrom(a_Socket, buf, buflen, 0, reinterpret_cast<sockaddr *>(&sa), &salen); + auto len = recvfrom(a_Socket, buf, sizeof(buf), 0, reinterpret_cast<sockaddr *>(&sa), &salen); if (len >= 0) { // Convert the remote IP address to a string: |