From 020d515a09c9dba3b9297a4a2933bf24d0cc0253 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sat, 13 Aug 2022 17:58:56 -0600 Subject: [PATCH] Remove manual disabling of `-Wuseless-cast` This warning is not being used so we don't need pragmas to work around it. --- cmake/CompilerWarnings.cmake | 7 ------- src/SFML/Audio/SoundFileReaderMp3.cpp | 4 ++-- src/SFML/Network/TcpSocket.cpp | 9 --------- src/SFML/Network/UdpSocket.cpp | 6 ------ 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index 9c783ad30..9747ccc27 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -69,17 +69,10 @@ function(set_target_warnings target) -Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist -Wduplicated-cond # warn if if / else chain has duplicated conditions -Wlogical-op # warn about logical operations being used where bitwise were probably wanted - # -Wuseless-cast # warn if you perform a cast to the same type (disabled because it is not portable as some type aliases might vary between platforms) $<$:-Wduplicated-branches> # warn if if / else branches have duplicated code ) endif() - if(SFML_COMPILER_CLANG OR SFML_COMPILER_CLANG_CL) - target_compile_options(${target} PRIVATE - -Wno-unknown-warning-option # do not warn on GCC-specific warning diagnostic pragmas - ) - endif() - # Disable certain deprecation warnings if(SFML_OS_WINDOWS) target_compile_definitions(${target} PRIVATE -D_CRT_SECURE_NO_WARNINGS) diff --git a/src/SFML/Audio/SoundFileReaderMp3.cpp b/src/SFML/Audio/SoundFileReaderMp3.cpp index b26eb92fa..3c192f27b 100644 --- a/src/SFML/Audio/SoundFileReaderMp3.cpp +++ b/src/SFML/Audio/SoundFileReaderMp3.cpp @@ -34,7 +34,7 @@ #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4242 4244 4267 4456 4706) -#else +#elif !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" #endif @@ -43,7 +43,7 @@ #ifdef _MSC_VER #pragma warning(pop) -#else +#elif !defined(__clang__) #pragma GCC diagnostic pop #endif diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index 675d8d32b..7e9aaefde 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -246,14 +246,11 @@ Socket::Status TcpSocket::send(const void* data, std::size_t size, std::size_t& int result = 0; for (sent = 0; sent < size; sent += static_cast(result)) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wuseless-cast" // Send a chunk of data result = static_cast(::send(getNativeHandle(), static_cast(data) + sent, static_cast(size - sent), flags)); -#pragma GCC diagnostic pop // Check for errors if (result < 0) @@ -284,12 +281,9 @@ Socket::Status TcpSocket::receive(void* data, std::size_t size, std::size_t& rec return Status::Error; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wuseless-cast" // Receive a chunk of bytes const int sizeReceived = static_cast( recv(getNativeHandle(), static_cast(data), static_cast(size), flags)); -#pragma GCC diagnostic pop // Check the number of bytes received if (sizeReceived > 0) @@ -340,15 +334,12 @@ Socket::Status TcpSocket::send(Packet& packet) // signature of `send` might change depending on whether Win32 or MinGW is // being used. #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wuseless-cast" -#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" // Send the data block std::size_t sent = 0; const Status status = send(m_blockToSendBuffer.data() + packet.m_sendPos, static_cast(m_blockToSendBuffer.size() - packet.m_sendPos), sent); -#pragma GCC diagnostic pop #pragma GCC diagnostic pop // In the case of a partial send, record the location to resume from diff --git a/src/SFML/Network/UdpSocket.cpp b/src/SFML/Network/UdpSocket.cpp index e57e55d0d..42dcc826c 100644 --- a/src/SFML/Network/UdpSocket.cpp +++ b/src/SFML/Network/UdpSocket.cpp @@ -114,8 +114,6 @@ Socket::Status UdpSocket::send(const void* data, std::size_t size, IpAddress rem // Build the target address sockaddr_in address = priv::SocketImpl::createAddress(remoteAddress.toInteger(), remotePort); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wuseless-cast" // Send the data (unlike TCP, all the data is always sent in one call) const int sent = static_cast( sendto(getNativeHandle(), @@ -124,7 +122,6 @@ Socket::Status UdpSocket::send(const void* data, std::size_t size, IpAddress rem 0, reinterpret_cast(&address), sizeof(address))); -#pragma GCC diagnostic pop // Check for errors if (sent < 0) @@ -156,8 +153,6 @@ Socket::Status UdpSocket::receive(void* data, // Data that will be filled with the other computer's address sockaddr_in address = priv::SocketImpl::createAddress(INADDR_ANY, 0); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wuseless-cast" // Receive a chunk of bytes priv::SocketImpl::AddrLength addressSize = sizeof(address); const int sizeReceived = static_cast( @@ -167,7 +162,6 @@ Socket::Status UdpSocket::receive(void* data, 0, reinterpret_cast(&address), &addressSize)); -#pragma GCC diagnostic pop // Check for errors if (sizeReceived < 0)