From e872a755949eff27017774888b7293ab13bab545 Mon Sep 17 00:00:00 2001 From: Ferry Huberts Date: Fri, 11 Aug 2023 09:07:15 +0200 Subject: [PATCH] Process review comments Signed-off-by: Ferry Huberts --- src/oatpp/algorithm/CRC.cpp | 2 +- src/oatpp/core/data/buffer/FIFOBuffer.cpp | 2 +- src/oatpp/core/data/buffer/Processor.cpp | 4 ++-- src/oatpp/core/data/share/MemoryLabel.hpp | 4 ++-- src/oatpp/core/data/stream/Stream.hpp | 2 +- src/oatpp/core/utils/String.cpp | 6 +++--- src/oatpp/encoding/Hex.cpp | 4 ++-- src/oatpp/encoding/Url.cpp | 4 ++-- src/oatpp/parser/json/Beautifier.cpp | 2 +- test/oatpp/core/data/mapping/type/StringTest.cpp | 1 + test/oatpp/core/data/stream/BufferStreamTest.cpp | 2 +- 11 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/oatpp/algorithm/CRC.cpp b/src/oatpp/algorithm/CRC.cpp index 6ef0c902..0b9d8dd4 100644 --- a/src/oatpp/algorithm/CRC.cpp +++ b/src/oatpp/algorithm/CRC.cpp @@ -64,7 +64,7 @@ p_uint32 CRC32::generateTable(v_uint32 poly) { v_uint32 CRC32::calc(const void *buffer, v_buff_size size, v_uint32 crc, v_uint32 initValue, v_uint32 xorOut, p_uint32 table) { - p_uint8 data = reinterpret_cast(const_cast(buffer)); + auto data = reinterpret_cast(buffer); crc = crc ^ initValue; for(v_buff_size i = 0; i < size; i++) { diff --git a/src/oatpp/core/data/buffer/FIFOBuffer.cpp b/src/oatpp/core/data/buffer/FIFOBuffer.cpp index 04676772..f241af75 100644 --- a/src/oatpp/core/data/buffer/FIFOBuffer.cpp +++ b/src/oatpp/core/data/buffer/FIFOBuffer.cpp @@ -239,7 +239,7 @@ v_io_size FIFOBuffer::write(const void *data, v_buff_size count) { size2 = count - size; } - std::memcpy(m_buffer, &(reinterpret_cast(const_cast(data)))[size], static_cast(size2)); + std::memcpy(m_buffer, &(reinterpret_cast(data))[size], static_cast(size2)); m_writePosition = size2; return (size + size2); diff --git a/src/oatpp/core/data/buffer/Processor.cpp b/src/oatpp/core/data/buffer/Processor.cpp index 58bd190f..719aae44 100644 --- a/src/oatpp/core/data/buffer/Processor.cpp +++ b/src/oatpp/core/data/buffer/Processor.cpp @@ -102,7 +102,7 @@ v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn, return Error::FLUSH_DATA_OUT; } - v_int32 i = 0; + v_buff_size i = 0; v_int32 res = Error::OK; while(res == Error::OK) { @@ -115,7 +115,7 @@ v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn, } data::buffer::InlineReadData* currDataOut = &dataOut; - if(i < static_cast(m_intermediateData.size())) { + if(i < m_intermediateData.size()) { currDataOut = &m_intermediateData[i]; } diff --git a/src/oatpp/core/data/share/MemoryLabel.hpp b/src/oatpp/core/data/share/MemoryLabel.hpp index 7963d3b5..4633ce24 100644 --- a/src/oatpp/core/data/share/MemoryLabel.hpp +++ b/src/oatpp/core/data/share/MemoryLabel.hpp @@ -308,7 +308,7 @@ namespace std { result_type operator()(oatpp::data::share::StringKeyLabel const& s) const noexcept { - auto data = reinterpret_cast(const_cast(s.getData())); + auto data = reinterpret_cast(s.getData()); result_type result = 0; for(v_buff_size i = 0; i < s.getSize(); i++) { v_char8 c = data[i]; @@ -328,7 +328,7 @@ namespace std { result_type operator()(oatpp::data::share::StringKeyLabelCI const& s) const noexcept { - auto data = reinterpret_cast(const_cast(s.getData())); + auto data = reinterpret_cast(s.getData()); result_type result = 0; for(v_buff_size i = 0; i < s.getSize(); i++) { v_char8 c = data[i] | 32; diff --git a/src/oatpp/core/data/stream/Stream.hpp b/src/oatpp/core/data/stream/Stream.hpp index 243e4955..2f484a5b 100644 --- a/src/oatpp/core/data/stream/Stream.hpp +++ b/src/oatpp/core/data/stream/Stream.hpp @@ -230,7 +230,7 @@ public: * @return - actual number of bytes written. &id:oatpp::v_io_size;. */ v_io_size writeSimple(const char* data){ - return writeSimple(reinterpret_cast(const_cast(data)), std::strlen(data)); + return writeSimple(data, std::strlen(data)); } /** diff --git a/src/oatpp/core/utils/String.cpp b/src/oatpp/core/utils/String.cpp index db7213f7..b2fc78e4 100644 --- a/src/oatpp/core/utils/String.cpp +++ b/src/oatpp/core/utils/String.cpp @@ -55,8 +55,8 @@ v_buff_size String::compareCI_ASCII(const void* data1, v_buff_size size1, const if(data1 == nullptr) return -1; if(data2 == nullptr) return 1; - auto d1 = reinterpret_cast(const_cast(data1)); - auto d2 = reinterpret_cast(const_cast(data2)); + auto d1 = reinterpret_cast(data1); + auto d2 = reinterpret_cast(data2); v_buff_size size = size1; if(size2 < size1) size = size2; @@ -70,7 +70,7 @@ v_buff_size String::compareCI_ASCII(const void* data1, v_buff_size size1, const if(b >= 'A' && b <= 'Z') b |= 32; if(a != b) { - return static_cast(a) - static_cast(b); + return static_cast(a) - static_cast(b); } } diff --git a/src/oatpp/encoding/Hex.cpp b/src/oatpp/encoding/Hex.cpp index f2101c69..f99f9374 100644 --- a/src/oatpp/encoding/Hex.cpp +++ b/src/oatpp/encoding/Hex.cpp @@ -86,7 +86,7 @@ void Hex::encode(data::stream::ConsistentOutputStream* stream, const void* data, v_buff_size size, const char* alphabet) { - p_char8 buffer = reinterpret_cast(const_cast(data)); + auto buffer = reinterpret_cast(data); v_char8 oneByteBuffer[2]; for(v_buff_size i = 0; i < size; i ++) { auto c = buffer[i]; @@ -101,7 +101,7 @@ void Hex::encode(data::stream::ConsistentOutputStream* stream, void Hex::decode(data::stream::ConsistentOutputStream* stream, const void* data, v_buff_size size, bool allowSeparators) { - p_char8 buffer = reinterpret_cast(const_cast(data)); + auto buffer = reinterpret_cast(data); v_char8 byte = 0; v_int32 shift = 4; for(v_buff_size i = 0; i < size; i ++) { diff --git a/src/oatpp/encoding/Url.cpp b/src/oatpp/encoding/Url.cpp index d1d11dd9..a4995d9c 100644 --- a/src/oatpp/encoding/Url.cpp +++ b/src/oatpp/encoding/Url.cpp @@ -65,7 +65,7 @@ void Url::Config::disallowCharRange(v_char8 from, v_char8 to) { void Url::encode(data::stream::ConsistentOutputStream *stream, const void *data, v_buff_size size, const Config& config) { - p_char8 pdata = reinterpret_cast(const_cast(data)); + auto pdata = reinterpret_cast(data); for(v_buff_size i = 0; i < size; i++) { v_char8 c = pdata[i]; @@ -83,7 +83,7 @@ void Url::encode(data::stream::ConsistentOutputStream *stream, const void *data, void Url::decode(data::stream::ConsistentOutputStream* stream, const void* data, v_buff_size size) { - p_char8 pdata = reinterpret_cast(const_cast(data)); + auto pdata = reinterpret_cast(data); v_buff_size i = 0; while (i < size) { diff --git a/src/oatpp/parser/json/Beautifier.cpp b/src/oatpp/parser/json/Beautifier.cpp index 8cea2d75..cd0110d9 100644 --- a/src/oatpp/parser/json/Beautifier.cpp +++ b/src/oatpp/parser/json/Beautifier.cpp @@ -53,7 +53,7 @@ v_io_size Beautifier::write(const void *data, v_buff_size count, async::Action& for(v_buff_size i = 0; i < count; i ++) { - v_char8 c = (reinterpret_cast(const_cast(data))) [i]; + v_char8 c = (reinterpret_cast(data)) [i]; if(m_isCharEscaped) { m_isCharEscaped = false; diff --git a/test/oatpp/core/data/mapping/type/StringTest.cpp b/test/oatpp/core/data/mapping/type/StringTest.cpp index 38735c5e..8e03211d 100644 --- a/test/oatpp/core/data/mapping/type/StringTest.cpp +++ b/test/oatpp/core/data/mapping/type/StringTest.cpp @@ -42,6 +42,7 @@ void StringTest::onRun() { oatpp::String s; OATPP_ASSERT(!s); OATPP_ASSERT(s == nullptr); + OATPP_ASSERT(s == static_cast(nullptr)); OATPP_ASSERT(s.getValueType() == oatpp::String::Class::getType()); OATPP_LOGI(TAG, "OK"); } diff --git a/test/oatpp/core/data/stream/BufferStreamTest.cpp b/test/oatpp/core/data/stream/BufferStreamTest.cpp index 2d441a32..ea3d6154 100644 --- a/test/oatpp/core/data/stream/BufferStreamTest.cpp +++ b/test/oatpp/core/data/stream/BufferStreamTest.cpp @@ -51,7 +51,7 @@ void BufferStreamTest::onRun() { OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float32ToStr(101.1f)); stream.setCurrentPosition(0); - stream << 101.1; + stream << static_cast(101.1); OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float64ToStr(101.1)); stream.setCurrentPosition(0);