From f6f2d27b85722eb4b15a371dd88d6dc661ccd582 Mon Sep 17 00:00:00 2001 From: Ferry Huberts Date: Tue, 15 Aug 2023 20:51:44 +0200 Subject: [PATCH 1/2] Fix compiler warnings (-Wlogical-op) Signed-off-by: Ferry Huberts --- cmake/compiler-flags.cmake | 2 +- src/oatpp/network/tcp/Connection.cpp | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/cmake/compiler-flags.cmake b/cmake/compiler-flags.cmake index 606e1726..8c29cbac 100644 --- a/cmake/compiler-flags.cmake +++ b/cmake/compiler-flags.cmake @@ -160,7 +160,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) #add_compiler_flags(5.1 "-Wsuggest-final-types") add_compiler_flags(6.1 "-Wduplicated-cond") - #add_compiler_flags(6.1 "-Wlogical-op") + add_compiler_flags(6.1 "-Wlogical-op") add_compiler_flags(6.1 "-Wnull-dereference") add_compiler_flags(7.1 "-Wduplicated-branches") diff --git a/src/oatpp/network/tcp/Connection.cpp b/src/oatpp/network/tcp/Connection.cpp index 20c301ed..68ad31c2 100644 --- a/src/oatpp/network/tcp/Connection.cpp +++ b/src/oatpp/network/tcp/Connection.cpp @@ -115,7 +115,19 @@ v_io_size Connection::write(const void *buff, v_buff_size count, async::Action& if(result < 0) { auto e = errno; - if(e == EAGAIN || e == EWOULDBLOCK){ + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlogical-op" +#endif + + bool retry = ((e == EAGAIN) || (e == EWOULDBLOCK)); + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + + if(retry){ if(m_mode == data::stream::ASYNCHRONOUS) { action = oatpp::async::Action::createIOWaitAction(m_handle, oatpp::async::Action::IOEventType::IO_EVENT_WRITE); } @@ -173,7 +185,19 @@ v_io_size Connection::read(void *buff, v_buff_size count, async::Action& action) if(result < 0) { auto e = errno; - if(e == EAGAIN || e == EWOULDBLOCK){ + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlogical-op" +#endif + + bool retry = ((e == EAGAIN) || (e == EWOULDBLOCK)); + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + + if(retry){ if(m_mode == data::stream::ASYNCHRONOUS) { action = oatpp::async::Action::createIOWaitAction(m_handle, oatpp::async::Action::IOEventType::IO_EVENT_READ); } From dfc5e913f8fafb92d4bec588f50dd743b6986187 Mon Sep 17 00:00:00 2001 From: Ferry Huberts Date: Sat, 19 Aug 2023 08:29:27 +0200 Subject: [PATCH 2/2] Process review comments Signed-off-by: Ferry Huberts --- src/oatpp/network/tcp/Connection.cpp | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/oatpp/network/tcp/Connection.cpp b/src/oatpp/network/tcp/Connection.cpp index 68ad31c2..a0362535 100644 --- a/src/oatpp/network/tcp/Connection.cpp +++ b/src/oatpp/network/tcp/Connection.cpp @@ -76,6 +76,11 @@ Connection::~Connection(){ close(); } +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlogical-op" +#endif + v_io_size Connection::write(const void *buff, v_buff_size count, async::Action& action){ #if defined(WIN32) || defined(_WIN32) @@ -116,17 +121,8 @@ v_io_size Connection::write(const void *buff, v_buff_size count, async::Action& if(result < 0) { auto e = errno; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wlogical-op" -#endif - bool retry = ((e == EAGAIN) || (e == EWOULDBLOCK)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - if(retry){ if(m_mode == data::stream::ASYNCHRONOUS) { action = oatpp::async::Action::createIOWaitAction(m_handle, oatpp::async::Action::IOEventType::IO_EVENT_WRITE); @@ -151,6 +147,15 @@ v_io_size Connection::write(const void *buff, v_buff_size count, async::Action& } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlogical-op" +#endif + v_io_size Connection::read(void *buff, v_buff_size count, async::Action& action){ #if defined(WIN32) || defined(_WIN32) @@ -186,17 +191,8 @@ v_io_size Connection::read(void *buff, v_buff_size count, async::Action& action) if(result < 0) { auto e = errno; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wlogical-op" -#endif - bool retry = ((e == EAGAIN) || (e == EWOULDBLOCK)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - if(retry){ if(m_mode == data::stream::ASYNCHRONOUS) { action = oatpp::async::Action::createIOWaitAction(m_handle, oatpp::async::Action::IOEventType::IO_EVENT_READ); @@ -221,6 +217,10 @@ v_io_size Connection::read(void *buff, v_buff_size count, async::Action& action) } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #if defined(WIN32) || defined(_WIN32) void Connection::setStreamIOMode(oatpp::data::stream::IOMode ioMode) {