Fix compiler warnings (-Wuseless-cast)

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
This commit is contained in:
Ferry Huberts 2023-08-05 11:58:14 +02:00
parent 96bff7a7ed
commit f116a9619a
5 changed files with 17 additions and 8 deletions

View File

@ -196,7 +196,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
add_compiler_flags(4.7 "-Wzero-as-null-pointer-constant")
#add_compiler_flags(4.8 "-Wuseless-cast")
add_compiler_flags(4.8 "-Wuseless-cast")
add_compiler_flags(4.9 "-Wconditionally-supported")

View File

@ -42,7 +42,7 @@ namespace oatpp {
constexpr const v_io_handle INVALID_IO_HANDLE = v_io_handle (-1);
#else
typedef int v_io_handle;
constexpr const v_io_handle INVALID_IO_HANDLE = v_io_handle (-1);
constexpr const v_io_handle INVALID_IO_HANDLE = (-1);
#endif
/**

View File

@ -241,7 +241,7 @@ void Environment::checkTypes(){
static_assert(sizeof(v_uint64) == 8, "");
static_assert(sizeof(v_float64) == 8, "");
v_int32 vInt32 = ~v_int32(1);
v_int32 vInt32 = ~(1);
v_int64 vInt64 = ~v_int64(1);
v_uint32 vUInt32 = ~v_uint32(1);
v_uint64 vUInt64 = ~v_uint64(1);

View File

@ -415,7 +415,16 @@ provider::ResourceHandle<oatpp::data::stream::IOStream> ConnectionProvider::get(
timeout.tv_sec = 1;
timeout.tv_usec = 0;
auto res = select(int(m_serverHandle + 1), &set, nullptr, nullptr, &timeout);
auto res = select(
#if defined(WIN32) || defined(_WIN32)
static_cast<int>(m_serverHandle + 1),
#else
m_serverHandle + 1,
#endif
&set,
nullptr,
nullptr,
&timeout);
if (res >= 0) {
break;

View File

@ -47,12 +47,12 @@ void BufferStreamTest::onRun() {
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::int32ToStr(101));
stream.setCurrentPosition(0);
stream << static_cast<v_float32>(101.1);
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float32ToStr(101.1f));
stream << static_cast<v_float32>(101.5);
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float32ToStr(101.5f));
stream.setCurrentPosition(0);
stream << static_cast<v_float64>(101.1);
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float64ToStr(101.1));
stream << static_cast<v_float64>(101.5f);
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float64ToStr(101.5));
stream.setCurrentPosition(0);
stream << true;