From 1f9ad05fa5020f9f5ea0ac33cff5f7bfc8f4626e Mon Sep 17 00:00:00 2001 From: Ferry Huberts Date: Sun, 13 Aug 2023 12:19:45 +0200 Subject: [PATCH] Fix compiler warnings in compilation units (-Wsign-conversion) Signed-off-by: Ferry Huberts --- cmake/compiler-flags.cmake | 2 +- src/oatpp/algorithm/CRC.cpp | 8 +-- src/oatpp/core/async/Executor.cpp | 4 +- src/oatpp/core/base/Environment.cpp | 18 +++---- src/oatpp/core/concurrency/Thread.cpp | 4 +- src/oatpp/core/data/buffer/Processor.cpp | 6 +-- src/oatpp/core/data/mapping/TypeResolver.cpp | 6 +-- .../core/data/mapping/type/Primitive.cpp | 4 +- src/oatpp/core/data/resource/InMemoryData.cpp | 2 +- src/oatpp/core/data/share/MemoryLabel.cpp | 8 +-- src/oatpp/core/data/share/StringTemplate.cpp | 4 +- src/oatpp/core/data/stream/BufferStream.cpp | 10 ++-- src/oatpp/core/data/stream/FileStream.cpp | 4 +- src/oatpp/core/parser/Caret.cpp | 18 +++---- src/oatpp/core/utils/ConversionUtils.cpp | 20 +++---- src/oatpp/core/utils/String.cpp | 10 ++-- src/oatpp/encoding/Base64.cpp | 54 +++++++++---------- src/oatpp/encoding/Hex.cpp | 26 ++++----- src/oatpp/encoding/Unicode.cpp | 25 ++++----- src/oatpp/encoding/Url.cpp | 12 ++--- src/oatpp/network/Url.cpp | 4 +- .../network/tcp/client/ConnectionProvider.cpp | 4 +- .../network/tcp/server/ConnectionProvider.cpp | 2 +- src/oatpp/parser/json/Beautifier.cpp | 6 +-- src/oatpp/parser/json/Utils.cpp | 42 +++++++-------- .../parser/json/mapping/Deserializer.cpp | 14 ++--- src/oatpp/parser/json/mapping/Serializer.cpp | 12 ++--- src/oatpp/web/mime/multipart/PartList.cpp | 2 +- .../web/mime/multipart/StatefulParser.cpp | 6 +-- src/oatpp/web/protocol/http/Http.cpp | 6 +-- .../web/protocol/http/encoding/Chunked.cpp | 4 +- .../http/incoming/SimpleBodyDecoder.cpp | 4 +- .../web/protocol/http/outgoing/BufferBody.cpp | 6 +-- .../protocol/http/outgoing/MultipartBody.cpp | 4 +- .../server/handler/AuthorizationHandler.cpp | 6 +-- src/oatpp/web/url/mapping/Pattern.cpp | 8 +-- test/oatpp/core/async/LockTest.cpp | 4 +- .../core/data/resource/InMemoryDataTest.cpp | 8 +-- test/oatpp/encoding/UrlTest.cpp | 4 +- test/oatpp/network/virtual_/InterfaceTest.cpp | 4 +- test/oatpp/network/virtual_/PipeTest.cpp | 2 +- test/oatpp/web/FullAsyncTest.cpp | 2 +- test/oatpp/web/FullTest.cpp | 2 +- test/oatpp/web/PipelineAsyncTest.cpp | 4 +- test/oatpp/web/PipelineTest.cpp | 4 +- .../web/mime/multipart/StatefulParserTest.cpp | 8 +-- 46 files changed, 209 insertions(+), 208 deletions(-) diff --git a/cmake/compiler-flags.cmake b/cmake/compiler-flags.cmake index de8002e4..ecacb931 100644 --- a/cmake/compiler-flags.cmake +++ b/cmake/compiler-flags.cmake @@ -128,7 +128,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) add_compiler_flags(4.6 "-Wpointer-arith") add_compiler_flags(4.6 "-Wredundant-decls") add_compiler_flags(4.6 "-Wshadow") - #add_compiler_flags(4.6 "-Wsign-conversion") + add_compiler_flags(4.6 "-Wsign-conversion") #add_compiler_flags(4.6 "-Wsuggest-attribute=const") add_compiler_flags(4.6 "-Wsuggest-attribute=noreturn") #add_compiler_flags(4.6 "-Wsuggest-attribute=pure") diff --git a/src/oatpp/algorithm/CRC.cpp b/src/oatpp/algorithm/CRC.cpp index 0b9d8dd4..cab59428 100644 --- a/src/oatpp/algorithm/CRC.cpp +++ b/src/oatpp/algorithm/CRC.cpp @@ -31,8 +31,8 @@ const p_uint32 CRC32::TABLE_04C11DB7 = generateTable(0x04C11DB7); v_uint32 CRC32::bitReverse(v_uint32 poly) { v_uint32 result = 0; for(v_int32 i = 0; i < 32; i ++) { - if((poly & (1 << i)) > 0) { - result |= 1 << (31 - i); + if((poly & (1U << i)) > 0) { + result |= (1U << (31 - i)); } } return result; @@ -44,7 +44,7 @@ p_uint32 CRC32::generateTable(v_uint32 poly) { v_uint32 polyReverse = bitReverse(poly); v_uint32 value; - for(v_int32 i = 0; i < 256; i++) { + for(v_uint32 i = 0; i < 256; i++) { value = i; for (v_int32 bit = 0; bit < 8; bit++) { if (value & 1) { @@ -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) { - auto data = reinterpret_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/async/Executor.cpp b/src/oatpp/core/async/Executor.cpp index 95065454..1bf1545a 100644 --- a/src/oatpp/core/async/Executor.cpp +++ b/src/oatpp/core/async/Executor.cpp @@ -94,7 +94,7 @@ Executor::Executor(v_int32 processorWorkersCount, v_int32 ioWorkersCount, v_int3 m_allWorkers.insert(m_allWorkers.end(), m_processorWorkers.begin(), m_processorWorkers.end()); std::vector> ioWorkers; - ioWorkers.reserve(ioWorkersCount); + ioWorkers.reserve(static_cast(ioWorkersCount)); switch(ioWorkerType) { case IO_WORKER_TYPE_NAIVE: { @@ -119,7 +119,7 @@ Executor::Executor(v_int32 processorWorkersCount, v_int32 ioWorkersCount, v_int3 linkWorkers(ioWorkers); std::vector> timerWorkers; - timerWorkers.reserve(timerWorkersCount); + timerWorkers.reserve(static_cast(timerWorkersCount)); for(v_int32 i = 0; i < timerWorkersCount; i++) { timerWorkers.push_back(std::make_shared()); } diff --git a/src/oatpp/core/base/Environment.cpp b/src/oatpp/core/base/Environment.cpp index 14aa6a17..f59db204 100644 --- a/src/oatpp/core/base/Environment.cpp +++ b/src/oatpp/core/base/Environment.cpp @@ -138,42 +138,42 @@ void DefaultLogger::enablePriority(v_uint32 priority) { if (priority > PRIORITY_E) { return; } - m_config.logMask |= (1 << priority); + m_config.logMask |= (1U << priority); } void DefaultLogger::disablePriority(v_uint32 priority) { if (priority > PRIORITY_E) { return; } - m_config.logMask &= ~(1 << priority); + m_config.logMask &= ~(1U << priority); } bool DefaultLogger::isLogPriorityEnabled(v_uint32 priority) { if (priority > PRIORITY_E) { return true; } - return m_config.logMask & (1 << priority); + return m_config.logMask & (1U << priority); } void LogCategory::enablePriority(v_uint32 priority) { if (priority > Logger::PRIORITY_E) { return; } - enabledPriorities |= (1 << priority); + enabledPriorities |= (1U << priority); } void LogCategory::disablePriority(v_uint32 priority) { if (priority > Logger::PRIORITY_E) { return; } - enabledPriorities &= ~(1 << priority); + enabledPriorities &= ~(1U << priority); } bool LogCategory::isLogPriorityEnabled(v_uint32 priority) { if (priority > Logger::PRIORITY_E) { return true; } - return enabledPriorities & (1 << priority); + return enabledPriorities & (1U << priority); } void Environment::init() { @@ -333,7 +333,7 @@ void Environment::log(v_uint32 priority, const std::string& tag, const std::stri void Environment::logFormatted(v_uint32 priority, const LogCategory& category, const char* message, ...) { - if (category.categoryEnabled && (category.enabledPriorities & (1 << priority))) { + if (category.categoryEnabled && (category.enabledPriorities & (1U << priority))) { va_list args; va_start(args, message); vlogFormatted(priority, category.tag, message, args); @@ -367,9 +367,9 @@ void Environment::vlogFormatted(v_uint32 priority, const std::string& tag, const allocsize = m_logger->getMaxFormattingBufferSize(); } auto buffer = std::unique_ptr(new char[allocsize]); - memset(buffer.get(), 0, allocsize); + memset(buffer.get(), 0, static_cast(allocsize)); // actually format - vsnprintf(buffer.get(), allocsize, message, args); + vsnprintf(buffer.get(), static_cast(allocsize), message, args); // call (user) providen log function log(priority, tag, buffer.get()); } diff --git a/src/oatpp/core/concurrency/Thread.cpp b/src/oatpp/core/concurrency/Thread.cpp index ec37be9e..2fd9c0ed 100644 --- a/src/oatpp/core/concurrency/Thread.cpp +++ b/src/oatpp/core/concurrency/Thread.cpp @@ -51,7 +51,7 @@ v_int32 setThreadAffinityToCpuRange(std::thread::native_handle_type nativeHandle CPU_ZERO(&cpuset); for(v_int32 i = firstCpuIndex; i <= lastCpuIndex; i++) { - CPU_SET(i, &cpuset); + CPU_SET(static_cast(i), &cpuset); } v_int32 result = pthread_setaffinity_np(nativeHandle, sizeof(cpu_set_t), &cpuset); @@ -76,7 +76,7 @@ v_int32 setThreadAffinityToCpuRange(std::thread::native_handle_type nativeHandle static v_int32 calcHardwareConcurrency() { #if !defined(OATPP_THREAD_HARDWARE_CONCURRENCY) - v_int32 concurrency = std::thread::hardware_concurrency(); + v_int32 concurrency = static_cast(std::thread::hardware_concurrency()); if(concurrency == 0) { OATPP_LOGD("[oatpp::concurrency:Thread::calcHardwareConcurrency()]", "Warning - failed to get hardware_concurrency. Setting hardware_concurrency=1"); concurrency = 1; diff --git a/src/oatpp/core/data/buffer/Processor.cpp b/src/oatpp/core/data/buffer/Processor.cpp index 4521f6a5..87fdd5db 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_buff_size i = 0; + size_t 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]; } @@ -123,7 +123,7 @@ v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn, res = p->iterate(*currDataIn, *currDataOut); } - const v_int32 numOfProcessors = v_int32(m_processors.size()); + const size_t numOfProcessors = m_processors.size(); switch (res) { case Error::PROVIDE_DATA_IN: diff --git a/src/oatpp/core/data/mapping/TypeResolver.cpp b/src/oatpp/core/data/mapping/TypeResolver.cpp index cc04d940..ab48096e 100644 --- a/src/oatpp/core/data/mapping/TypeResolver.cpp +++ b/src/oatpp/core/data/mapping/TypeResolver.cpp @@ -28,7 +28,7 @@ namespace oatpp { namespace data { namespace mapping { TypeResolver::TypeResolver() { - m_knownClasses.resize(data::mapping::type::ClassId::getClassCount(), false); + m_knownClasses.resize(static_cast(data::mapping::type::ClassId::getClassCount()), false); addKnownClasses({ data::mapping::type::__class::String::CLASS_ID, @@ -64,7 +64,7 @@ TypeResolver::TypeResolver() { } void TypeResolver::setKnownClass(const type::ClassId& classId, bool isKnown) { - const v_uint32 id = classId.id; + const v_uint32 id = static_cast(classId.id); if(id >= m_knownClasses.size()) { m_knownClasses.resize(id + 1, false); } @@ -78,7 +78,7 @@ void TypeResolver::addKnownClasses(const std::vector& knownClasse } bool TypeResolver::isKnownClass(const type::ClassId& classId) const { - const v_uint32 id = classId.id; + const v_uint32 id = static_cast(classId.id); if(id < m_knownClasses.size()) { return m_knownClasses[id]; } diff --git a/src/oatpp/core/data/mapping/type/Primitive.cpp b/src/oatpp/core/data/mapping/type/Primitive.cpp index 60b554f1..49146c4d 100644 --- a/src/oatpp/core/data/mapping/type/Primitive.cpp +++ b/src/oatpp/core/data/mapping/type/Primitive.cpp @@ -45,7 +45,7 @@ String String::loadFromFile(const char* filename) { if (file.is_open()) { auto result = data::mapping::type::String(file.tellg()); file.seekg(0, std::ios::beg); - file.read(const_cast(result->data()), result->size()); + file.read(const_cast(result->data()), static_cast(result->size())); file.close(); return result; } @@ -55,7 +55,7 @@ String String::loadFromFile(const char* filename) { void String::saveToFile(const char* filename) const { std::ofstream fs(filename, std::ios::out | std::ios::binary); if(m_ptr != nullptr) { - fs.write(m_ptr->data(), m_ptr->size()); + fs.write(m_ptr->data(), static_cast(m_ptr->size())); } fs.close(); } diff --git a/src/oatpp/core/data/resource/InMemoryData.cpp b/src/oatpp/core/data/resource/InMemoryData.cpp index e9770c31..285ea6e8 100644 --- a/src/oatpp/core/data/resource/InMemoryData.cpp +++ b/src/oatpp/core/data/resource/InMemoryData.cpp @@ -69,7 +69,7 @@ oatpp::String InMemoryData::getInMemoryData() { v_int64 InMemoryData::getKnownSize() { if(m_handle && m_handle->data) { - return m_handle->data->size(); + return static_cast(m_handle->data->size()); } return 0; } diff --git a/src/oatpp/core/data/share/MemoryLabel.cpp b/src/oatpp/core/data/share/MemoryLabel.cpp index 4887aa76..16217ca4 100644 --- a/src/oatpp/core/data/share/MemoryLabel.cpp +++ b/src/oatpp/core/data/share/MemoryLabel.cpp @@ -39,11 +39,11 @@ StringKeyLabel::StringKeyLabel(const std::shared_ptr& memHandle, co {} StringKeyLabel::StringKeyLabel(const char* constText) - : oatpp::data::share::MemoryLabel(nullptr, constText, std::strlen(constText)) + : oatpp::data::share::MemoryLabel(nullptr, constText, static_cast(std::strlen(constText))) {} StringKeyLabel::StringKeyLabel(const String& str) - : oatpp::data::share::MemoryLabel(str.getPtr(), str->data(), str->size()) + : oatpp::data::share::MemoryLabel(str.getPtr(), str->data(), static_cast(str->size())) {} StringKeyLabelCI::StringKeyLabelCI(const std::shared_ptr& memHandle, const char* data, v_buff_size size) @@ -51,11 +51,11 @@ StringKeyLabelCI::StringKeyLabelCI(const std::shared_ptr& memHandle {} StringKeyLabelCI::StringKeyLabelCI(const char* constText) - : oatpp::data::share::MemoryLabel(nullptr, constText, std::strlen(constText)) + : oatpp::data::share::MemoryLabel(nullptr, constText, static_cast(std::strlen(constText))) {} StringKeyLabelCI::StringKeyLabelCI(const String& str) - : oatpp::data::share::MemoryLabel(str.getPtr(), str->data(), str->size()) + : oatpp::data::share::MemoryLabel(str.getPtr(), str->data(), static_cast(str->size())) {} }}} diff --git a/src/oatpp/core/data/share/StringTemplate.cpp b/src/oatpp/core/data/share/StringTemplate.cpp index 59872cb2..2ad16977 100644 --- a/src/oatpp/core/data/share/StringTemplate.cpp +++ b/src/oatpp/core/data/share/StringTemplate.cpp @@ -99,14 +99,14 @@ void StringTemplate::format(stream::ConsistentOutputStream* stream, ValueProvide stream->writeSimple(m_text->data() + prevPos, var.posStart - prevPos); } - stream->writeSimple(value->data(), value->size()); + stream->writeSimple(value->data(), static_cast(value->size())); prevPos = var.posEnd + 1; } if(static_cast(prevPos) < m_text->size()) { - stream->writeSimple(m_text->data() + prevPos, m_text->size() - prevPos); + stream->writeSimple(m_text->data() + prevPos, static_cast(m_text->size()) - prevPos); } } diff --git a/src/oatpp/core/data/stream/BufferStream.cpp b/src/oatpp/core/data/stream/BufferStream.cpp index 3b228394..414e89a8 100644 --- a/src/oatpp/core/data/stream/BufferStream.cpp +++ b/src/oatpp/core/data/stream/BufferStream.cpp @@ -53,7 +53,7 @@ v_io_size BufferOutputStream::write(const void *data, v_buff_size count, async:: reserveBytesUpfront(count); - std::memcpy(m_data + m_position, data, count); + std::memcpy(m_data + m_position, data, static_cast(count)); m_position += count; return count; @@ -90,7 +90,7 @@ void BufferOutputStream::reserveBytesUpfront(v_buff_size count) { p_char8 newData = new v_char8[newCapacity]; - std::memcpy(newData, m_data, m_position); + std::memcpy(newData, m_data, static_cast(m_position)); delete [] m_data; m_data = newData; m_capacity = newCapacity; @@ -189,7 +189,7 @@ BufferInputStream::BufferInputStream(const std::shared_ptr& memoryH {} BufferInputStream::BufferInputStream(const oatpp::String& data, const std::shared_ptr& captureData) - : BufferInputStream(data.getPtr(), reinterpret_cast(const_cast(data->data())), data->size(), captureData) + : BufferInputStream(data.getPtr(), reinterpret_cast(const_cast(data->data())), static_cast(data->size()), captureData) {} void BufferInputStream::reset(const std::shared_ptr& memoryHandle, @@ -220,7 +220,7 @@ v_io_size BufferInputStream::read(void *data, v_buff_size count, async::Action& if(desiredAmount > m_size - m_position) { desiredAmount = m_size - m_position; } - std::memcpy(data, &m_data[m_position], desiredAmount); + std::memcpy(data, &m_data[m_position], static_cast(desiredAmount)); m_position += desiredAmount; return desiredAmount; } @@ -264,7 +264,7 @@ v_io_size BufferInputStream::peek(void *data, v_buff_size count, async::Action & if(desiredAmount > m_size - m_position) { desiredAmount = m_size - m_position; } - std::memcpy(data, &m_data[m_position], desiredAmount); + std::memcpy(data, &m_data[m_position], static_cast(desiredAmount)); return desiredAmount; } diff --git a/src/oatpp/core/data/stream/FileStream.cpp b/src/oatpp/core/data/stream/FileStream.cpp index b458e83a..25a2162f 100644 --- a/src/oatpp/core/data/stream/FileStream.cpp +++ b/src/oatpp/core/data/stream/FileStream.cpp @@ -68,7 +68,7 @@ std::FILE* FileInputStream::getFile() { v_io_size FileInputStream::read(void *data, v_buff_size count, async::Action& action) { (void) action; if(m_file != nullptr) { - return std::fread(data, 1, count, m_file); + return static_cast(std::fread(data, 1, static_cast(count), m_file)); } return oatpp::IOError::BROKEN_PIPE; } @@ -147,7 +147,7 @@ std::FILE* FileOutputStream::getFile() { v_io_size FileOutputStream::write(const void *data, v_buff_size count, async::Action& action) { (void) action; - return std::fwrite(data, 1, count, m_file); + return static_cast(std::fwrite(data, 1, static_cast(count), m_file)); } void FileOutputStream::setOutputStreamIOMode(IOMode ioMode) { diff --git a/src/oatpp/core/parser/Caret.cpp b/src/oatpp/core/parser/Caret.cpp index a1ad080f..f12cf7e7 100644 --- a/src/oatpp/core/parser/Caret.cpp +++ b/src/oatpp/core/parser/Caret.cpp @@ -86,7 +86,7 @@ namespace oatpp { namespace parser { if(end == -1){ end = m_caret->m_pos; } - return std::string(&m_caret->m_data[m_start], end - m_start); + return std::string(&m_caret->m_data[m_start], static_cast(end - m_start)); } Caret::Label::operator bool() const { @@ -125,7 +125,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() { // Caret Caret::Caret(const char* text) - : Caret(text, std::strlen(text)) + : Caret(text, static_cast(std::strlen(text))) {} Caret::Caret(const char* parseData, v_buff_size dataSize) @@ -137,7 +137,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() { {} Caret::Caret(const oatpp::String& str) - : Caret(str->data(), str->size()) + : Caret(str->data(), static_cast(str->size())) { m_dataMemoryHandle = str.getPtr(); } @@ -248,7 +248,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() { } bool Caret::skipCharsFromSet(const char* set){ - return skipCharsFromSet(set, std::strlen(set)); + return skipCharsFromSet(set, static_cast(std::strlen(set))); } bool Caret::skipCharsFromSet(const char* set, v_buff_size setSize){ @@ -265,7 +265,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() { } v_buff_size Caret::findCharFromSet(const char* set){ - return findCharFromSet(set, std::strlen(set)); + return findCharFromSet(set, static_cast(std::strlen(set))); } v_buff_size Caret::findCharFromSet(const char* set, v_buff_size setSize){ @@ -395,7 +395,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() { } bool Caret::isAtText(const char* text, bool skipIfTrue){ - return isAtText(text, std::strlen(text), skipIfTrue); + return isAtText(text, static_cast(std::strlen(text)), skipIfTrue); } bool Caret::isAtText(const char* text, v_buff_size textSize, bool skipIfTrue){ @@ -423,7 +423,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() { } bool Caret::isAtTextNCS(const char* text, bool skipIfTrue){ - return isAtTextNCS(text, std::strlen(text), skipIfTrue); + return isAtTextNCS(text, static_cast(std::strlen(text)), skipIfTrue); } bool Caret::isAtTextNCS(const char* text, v_buff_size textSize, bool skipIfTrue){ @@ -492,7 +492,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() { } bool Caret::findText(const char* text) { - return findText(text, std::strlen(text)); + return findText(text, static_cast(std::strlen(text))); } bool Caret::findText(const char* text, v_buff_size textSize) { @@ -501,7 +501,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() { } bool Caret::isAtCharFromSet(const char* set) const{ - return isAtCharFromSet(set, std::strlen(set)); + return isAtCharFromSet(set, static_cast(std::strlen(set))); } bool Caret::isAtCharFromSet(const char* set, v_buff_size setSize) const{ diff --git a/src/oatpp/core/utils/ConversionUtils.cpp b/src/oatpp/core/utils/ConversionUtils.cpp index f0315695..a0f3507d 100644 --- a/src/oatpp/core/utils/ConversionUtils.cpp +++ b/src/oatpp/core/utils/ConversionUtils.cpp @@ -77,19 +77,19 @@ namespace oatpp { namespace utils { namespace conversion { } v_buff_size int32ToCharSequence(v_int32 value, p_char8 data, v_buff_size n) { - return snprintf(reinterpret_cast(data), n, "%ld", static_cast(value)); + return snprintf(reinterpret_cast(data), static_cast(n), "%ld", static_cast(value)); } v_buff_size uint32ToCharSequence(v_uint32 value, p_char8 data, v_buff_size n) { - return snprintf(reinterpret_cast(data), n, "%lu", static_cast(value)); + return snprintf(reinterpret_cast(data), static_cast(n), "%lu", static_cast(value)); } v_buff_size int64ToCharSequence(v_int64 value, p_char8 data, v_buff_size n) { - return snprintf(reinterpret_cast(data), n, "%lld", static_cast(value)); + return snprintf(reinterpret_cast(data), static_cast(n), "%lld", static_cast(value)); } v_buff_size uint64ToCharSequence(v_uint64 value, p_char8 data, v_buff_size n) { - return snprintf(reinterpret_cast(data), n, "%llu", static_cast(value)); + return snprintf(reinterpret_cast(data), static_cast(n), "%llu", static_cast(value)); } oatpp::String int32ToStr(v_int32 value){ @@ -132,7 +132,7 @@ namespace oatpp { namespace utils { namespace conversion { v_char8 buff [16]; auto size = int32ToCharSequence(value, &buff[0], 16); if(size > 0){ - return std::string(reinterpret_cast(buff), size); + return std::string(reinterpret_cast(buff), static_cast(size)); } return nullptr; } @@ -141,7 +141,7 @@ namespace oatpp { namespace utils { namespace conversion { v_char8 buff [16]; auto size = uint32ToCharSequence(value, &buff[0], 16); if(size > 0){ - return std::string(reinterpret_cast(buff), size); + return std::string(reinterpret_cast(buff), static_cast(size)); } return nullptr; } @@ -150,7 +150,7 @@ namespace oatpp { namespace utils { namespace conversion { v_char8 buff [32]; v_int32 size = v_int32(int64ToCharSequence(value, &buff[0], 32)); if(size > 0){ - return std::string(reinterpret_cast(buff), size); + return std::string(reinterpret_cast(buff), static_cast(size)); } return nullptr; } @@ -159,7 +159,7 @@ namespace oatpp { namespace utils { namespace conversion { v_char8 buff [32]; auto size = uint64ToCharSequence(value, &buff[0], 32); if(size > 0){ - return std::string(reinterpret_cast(buff), size); + return std::string(reinterpret_cast(buff), static_cast(size)); } return nullptr; } @@ -189,11 +189,11 @@ namespace oatpp { namespace utils { namespace conversion { } v_buff_size float32ToCharSequence(v_float32 value, p_char8 data, v_buff_size n, const char* format) { - return snprintf(reinterpret_cast(data), n, format, static_cast(value)); + return snprintf(reinterpret_cast(data), static_cast(n), format, static_cast(value)); } v_buff_size float64ToCharSequence(v_float64 value, p_char8 data, v_buff_size n, const char* format) { - return snprintf(reinterpret_cast(data), n, format, value); + return snprintf(reinterpret_cast(data), static_cast(n), format, value); } oatpp::String float32ToStr(v_float32 value, const char* format) { diff --git a/src/oatpp/core/utils/String.cpp b/src/oatpp/core/utils/String.cpp index b2fc78e4..66529cc7 100644 --- a/src/oatpp/core/utils/String.cpp +++ b/src/oatpp/core/utils/String.cpp @@ -34,18 +34,18 @@ v_buff_size String::compare(const void* data1, v_buff_size size1, const void* da if(data2 == nullptr) return 1; if(size1 < size2) { - auto res = std::memcmp(data1, data2, size1); + auto res = std::memcmp(data1, data2, static_cast(size1)); if(res == 0) return -1; return res; } if(size1 > size2) { - auto res = std::memcmp(data1, data2, size2); + auto res = std::memcmp(data1, data2, static_cast(size2)); if(res == 0) return 1; return res; } - return std::memcmp(data1, data2, size1); + return std::memcmp(data1, data2, static_cast(size1)); } @@ -63,8 +63,8 @@ v_buff_size String::compareCI_ASCII(const void* data1, v_buff_size size1, const for(v_buff_size i = 0; i < size; i ++) { - v_char8 a = d1[i]; - v_char8 b = d2[i]; + v_char8 a = static_cast(d1[i]); + v_char8 b = static_cast(d2[i]); if(a >= 'A' && a <= 'Z') a |= 32; if(b >= 'A' && b <= 'Z') b |= 32; diff --git a/src/oatpp/encoding/Base64.cpp b/src/oatpp/encoding/Base64.cpp index 913007d0..e07f1cf1 100644 --- a/src/oatpp/encoding/Base64.cpp +++ b/src/oatpp/encoding/Base64.cpp @@ -66,14 +66,14 @@ v_buff_size Base64::calcDecodedStringSize(const char* data, v_buff_size size, v_ base64StrLength = size; - v_char8 auxChar1 = auxiliaryChars[0]; - v_char8 auxChar2 = auxiliaryChars[1]; - v_char8 paddingChar = auxiliaryChars[2]; + v_char8 auxChar1 = static_cast(auxiliaryChars[0]); + v_char8 auxChar2 = static_cast(auxiliaryChars[1]); + v_char8 paddingChar = static_cast(auxiliaryChars[2]); v_buff_size i = 0; while (i < size) { - v_char8 a = data[i]; + v_char8 a = static_cast(data[i]); bool isValidChar = (a >= 'A' && a <='Z') || (a >= 'a' && a <='z') || (a >= '0' && a <='9') || (a == auxChar1) || (a == auxChar2); if(!isValidChar) { @@ -118,10 +118,10 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp v_char8 b0 = bdata[pos]; v_char8 b1 = bdata[pos + 1]; v_char8 b2 = bdata[pos + 2]; - resultData[0] = alphabet[(b0 & 252) >> 2]; - resultData[1] = alphabet[((b0 & 3) << 4) | ((b1 >> 4) & 15)]; - resultData[2] = alphabet[((b1 & 15) << 2) | ((b2 >> 6) & 3)]; - resultData[3] = alphabet[(b2 & 63)]; + resultData[0] = static_cast(alphabet[(b0 & 252) >> 2]); + resultData[1] = static_cast(alphabet[((b0 & 3) << 4) | ((b1 >> 4) & 15)]); + resultData[2] = static_cast(alphabet[((b1 & 15) << 2) | ((b2 >> 6) & 3)]); + resultData[3] = static_cast(alphabet[(b2 & 63)]); resultData += 4; pos += 3; @@ -130,16 +130,16 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp if(pos + 1 < size) { v_char8 b0 = bdata[pos]; v_char8 b1 = bdata[pos + 1]; - resultData[0] = alphabet[(b0 & 252) >> 2]; - resultData[1] = alphabet[((b0 & 3) << 4) | ((b1 >> 4) & 15)]; - resultData[2] = alphabet[((b1 & 15) << 2)]; - resultData[3] = alphabet[64]; + resultData[0] = static_cast(alphabet[(b0 & 252) >> 2]); + resultData[1] = static_cast(alphabet[((b0 & 3) << 4) | ((b1 >> 4) & 15)]); + resultData[2] = static_cast(alphabet[((b1 & 15) << 2)]); + resultData[3] = static_cast(alphabet[64]); } else if(pos < size) { v_char8 b0 = bdata[pos]; - resultData[0] = alphabet[(b0 & 252) >> 2]; - resultData[1] = alphabet[(b0 & 3) << 4]; - resultData[2] = alphabet[64]; - resultData[3] = alphabet[64]; + resultData[0] = static_cast(alphabet[(b0 & 252) >> 2]); + resultData[1] = static_cast(alphabet[(b0 & 3) << 4]); + resultData[2] = static_cast(alphabet[64]); + resultData[3] = static_cast(alphabet[64]); } return result; @@ -147,7 +147,7 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp } oatpp::String Base64::encode(const oatpp::String& data, const char* alphabet) { - return encode(data->data(), data->size(), alphabet); + return encode(data->data(), static_cast(data->size()), alphabet); } oatpp::String Base64::decode(const char* data, v_buff_size size, const char* auxiliaryChars) { @@ -162,10 +162,10 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux p_char8 resultData = reinterpret_cast(const_cast(result->data())); v_buff_size pos = 0; while (pos + 3 < base64StrLength) { - v_char8 b0 = getAlphabetCharIndex(data[pos], auxiliaryChars); - v_char8 b1 = getAlphabetCharIndex(data[pos + 1], auxiliaryChars); - v_char8 b2 = getAlphabetCharIndex(data[pos + 2], auxiliaryChars); - v_char8 b3 = getAlphabetCharIndex(data[pos + 3], auxiliaryChars); + v_char8 b0 = getAlphabetCharIndex(static_cast(data[pos]), auxiliaryChars); + v_char8 b1 = getAlphabetCharIndex(static_cast(data[pos + 1]), auxiliaryChars); + v_char8 b2 = getAlphabetCharIndex(static_cast(data[pos + 2]), auxiliaryChars); + v_char8 b3 = getAlphabetCharIndex(static_cast(data[pos + 3]), auxiliaryChars); resultData[0] = static_cast((b0 << 2) | ((b1 >> 4) & 3)); resultData[1] = static_cast(((b1 & 15) << 4) | ((b2 >> 2) & 15)); @@ -177,14 +177,14 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux v_buff_size posDiff = base64StrLength - pos; if(posDiff == 3) { - v_char8 b0 = getAlphabetCharIndex(data[pos], auxiliaryChars); - v_char8 b1 = getAlphabetCharIndex(data[pos + 1], auxiliaryChars); - v_char8 b2 = getAlphabetCharIndex(data[pos + 2], auxiliaryChars); + v_char8 b0 = getAlphabetCharIndex(static_cast(data[pos]), auxiliaryChars); + v_char8 b1 = getAlphabetCharIndex(static_cast(data[pos + 1]), auxiliaryChars); + v_char8 b2 = getAlphabetCharIndex(static_cast(data[pos + 2]), auxiliaryChars); resultData[0] = static_cast((b0 << 2) | ((b1 >> 4) & 3)); resultData[1] = static_cast(((b1 & 15) << 4) | ((b2 >> 2) & 15)); } else if(posDiff == 2) { - v_char8 b0 = getAlphabetCharIndex(data[pos], auxiliaryChars); - v_char8 b1 = getAlphabetCharIndex(data[pos + 1], auxiliaryChars); + v_char8 b0 = getAlphabetCharIndex(static_cast(data[pos]), auxiliaryChars); + v_char8 b1 = getAlphabetCharIndex(static_cast(data[pos + 1]), auxiliaryChars); resultData[0] = static_cast((b0 << 2) | ((b1 >> 4) & 3)); } @@ -193,7 +193,7 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux } oatpp::String Base64::decode(const oatpp::String& data, const char* auxiliaryChars) { - return decode(data->data(), data->size(), auxiliaryChars); + return decode(data->data(), static_cast(data->size()), auxiliaryChars); } }} diff --git a/src/oatpp/encoding/Hex.cpp b/src/oatpp/encoding/Hex.cpp index 8cd6b702..27a0fbe0 100644 --- a/src/oatpp/encoding/Hex.cpp +++ b/src/oatpp/encoding/Hex.cpp @@ -36,10 +36,10 @@ const char* Hex::ALPHABET_UPPER = "0123456789ABCDEF"; const char* Hex::ALPHABET_LOWER = "0123456789abcdef"; void Hex::writeUInt16(v_uint16 value, p_char8 buffer){ - *(reinterpret_cast(buffer)) = htonl((ALPHABET_UPPER[ value & 0x000F ] ) | - (ALPHABET_UPPER[(value & 0x00F0) >> 4] << 8) | - (ALPHABET_UPPER[(value & 0x0F00) >> 8] << 16) | - (ALPHABET_UPPER[(value & 0xF000) >> 12] << 24)); + *(reinterpret_cast(buffer)) = htonl((static_cast(ALPHABET_UPPER[ value & 0x000F ]) ) | + (static_cast(ALPHABET_UPPER[(value & 0x00F0) >> 4]) << 8) | + (static_cast(ALPHABET_UPPER[(value & 0x0F00) >> 8]) << 16) | + (static_cast(ALPHABET_UPPER[(value & 0xF000) >> 12]) << 24)); } @@ -50,8 +50,8 @@ void Hex::writeUInt32(v_uint32 value, p_char8 buffer){ v_int32 Hex::readUInt16(const char* buffer, v_uint16& value) { value = 0; - for(v_int32 i = 0; i < 4; i++){ - v_char8 a = buffer[i]; + for(v_uint32 i = 0; i < 4; i++){ + v_char8 a = static_cast(buffer[i]); if(a >= '0' && a <= '9') { value |= static_cast((a - '0') << ((3 - i) << 2)); } else if (a >= 'A' && a <= 'F') { @@ -67,14 +67,14 @@ v_int32 Hex::readUInt16(const char* buffer, v_uint16& value) { v_int32 Hex::readUInt32(const char* buffer, v_uint32& value) { value = 0; - for(v_int32 i = 0; i < 8; i++){ - v_char8 a = buffer[i]; + for(v_uint32 i = 0; i < 8; i++){ + v_char8 a = static_cast(buffer[i]); if(a >= '0' && a <= '9') { - value |= (a - '0') << ((7 - i) << 2); + value |= static_cast(a - '0') << ((7 - i) << 2); } else if (a >= 'A' && a <= 'F') { - value |= (a - 'A' + 10) << ((7 - i) << 2); + value |= static_cast(a - 'A' + 10) << ((7 - i) << 2); } else if (a >= 'a' && a <= 'f') { - value |= (a - 'a' + 10) << ((7 - i) << 2); + value |= static_cast(a - 'a' + 10) << ((7 - i) << 2); } else { return ERROR_UNKNOWN_SYMBOL; } @@ -87,9 +87,9 @@ void Hex::encode(data::stream::ConsistentOutputStream* stream, const char* alphabet) { auto buffer = reinterpret_cast(data); - v_char8 oneByteBuffer[2]; + char oneByteBuffer[2]; for(v_buff_size i = 0; i < size; i ++) { - auto c = buffer[i]; + v_char8 c = static_cast(buffer[i]); v_char8 b1 = 0x0F & (c >> 4); v_char8 b2 = 0x0F & (c); oneByteBuffer[0] = alphabet[b1]; diff --git a/src/oatpp/encoding/Unicode.cpp b/src/oatpp/encoding/Unicode.cpp index 90f0be48..ef839b1e 100644 --- a/src/oatpp/encoding/Unicode.cpp +++ b/src/oatpp/encoding/Unicode.cpp @@ -75,7 +75,7 @@ v_buff_size Unicode::getUtf8CharSequenceLengthForCode(v_uint32 code){ } v_int32 Unicode::encodeUtf8Char(const char* sequence, v_buff_size& length){ - v_char8 byte = sequence[0]; + v_char8 byte = static_cast(sequence[0]); if(byte > 127){ v_int32 code; if((byte | 32) != byte){ @@ -115,34 +115,35 @@ v_int32 Unicode::encodeUtf8Char(const char* sequence, v_buff_size& length){ } } -v_buff_size Unicode::decodeUtf8Char(v_int32 code, p_char8 buffer) { +v_buff_size Unicode::decodeUtf8Char(v_int32 signed_code, p_char8 buffer) { + v_uint32 code = static_cast(signed_code); if(code >= 0x00000080 && code < 0x00000800){ - *(reinterpret_cast(buffer)) = htons(((((code >> 6) & 31) | 192) << 8) | ((code & 63) | 128)); + *(reinterpret_cast(buffer)) = static_cast(htons(((((code >> 6) & 31) | 192) << 8) | ((code & 63) | 128))); return 2; } else if(code >= 0x00000800 && code < 0x00010000){ - *(reinterpret_cast(buffer)) = htons((((( code >> 12 ) & 15) | 224) << 8) | - (((code >> 6 ) & 63) | 128)); + *(reinterpret_cast(buffer)) = static_cast(htons((((( code >> 12 ) & 15) | 224) << 8) | + (((code >> 6 ) & 63) | 128))); buffer[2] = (code & 63) | 128; return 3; } else if(code >= 0x00010000 && code < 0x00200000){ - *(reinterpret_cast(buffer)) = htonl(((((code >> 18 ) & 7) | 240) << 24) | + *(reinterpret_cast(buffer)) = static_cast(htonl(((((code >> 18 ) & 7) | 240) << 24) | ((((code >> 12 ) & 63) | 128) << 16) | ((((code >> 6 ) & 63) | 128) << 8) | - (( code & 63) | 128) ); + (( code & 63) | 128) )); return 4; } else if(code >= 0x00200000 && code < 0x04000000){ - *(reinterpret_cast(buffer)) = htonl(((((code >> 24 ) & 3) | 248) << 24) | + *(reinterpret_cast(buffer)) = static_cast(htonl(((((code >> 24 ) & 3) | 248) << 24) | ((((code >> 18 ) & 63) | 128) << 16) | ((((code >> 12 ) & 63) | 128) << 8) | - (((code >> 6 ) & 63) | 128)); + (((code >> 6 ) & 63) | 128))); buffer[4] = (code & 63) | 128; return 5; } else if(code >= 0x04000000){ - *(reinterpret_cast(buffer)) = htonl(((((code >> 30 ) & 1) | 252) << 24) | + *(reinterpret_cast(buffer)) = static_cast(htonl(((((code >> 30 ) & 1) | 252) << 24) | ((((code >> 24 ) & 63) | 128) << 16) | ((((code >> 18 ) & 63) | 128) << 8) | - (((code >> 12 ) & 63) | 128)); - *(reinterpret_cast(&buffer[4])) = htons(((((code >> 6 ) & 63) | 128) << 8) | (code & 63)); + (((code >> 12 ) & 63) | 128))); + *(reinterpret_cast(&buffer[4])) = static_cast(htons(((((code >> 6 ) & 63) | 128) << 8) | (code & 63))); return 6; } buffer[0] = v_char8(code); diff --git a/src/oatpp/encoding/Url.cpp b/src/oatpp/encoding/Url.cpp index a4995d9c..fcc2e011 100644 --- a/src/oatpp/encoding/Url.cpp +++ b/src/oatpp/encoding/Url.cpp @@ -68,7 +68,7 @@ void Url::encode(data::stream::ConsistentOutputStream *stream, const void *data, auto pdata = reinterpret_cast(data); for(v_buff_size i = 0; i < size; i++) { - v_char8 c = pdata[i]; + v_char8 c = static_cast(pdata[i]); if(config.allowedChars[c]) { stream->writeCharSimple(c); } else if(c == ' ' && config.spaceToPlus) { @@ -88,7 +88,7 @@ void Url::decode(data::stream::ConsistentOutputStream* stream, const void* data, while (i < size) { - v_char8 c = pdata[i]; + v_char8 c = static_cast(pdata[i]); if(c == '%') { if(size - i > 1) { Hex::decode(stream, pdata + i + 1, 2); @@ -109,14 +109,14 @@ void Url::decode(data::stream::ConsistentOutputStream* stream, const void* data, } oatpp::String Url::encode(const oatpp::String data, const Config& config) { - data::stream::BufferOutputStream stream(data->size() * 3); - encode(&stream, data->data(), data->size(), config); + data::stream::BufferOutputStream stream(static_cast(data->size() * 3)); + encode(&stream, data->data(), static_cast(data->size()), config); return stream.toString(); } oatpp::String Url::decode(const oatpp::String data) { - data::stream::BufferOutputStream stream(data->size()); - decode(&stream, data->data(), data->size()); + data::stream::BufferOutputStream stream(static_cast(data->size())); + decode(&stream, data->data(), static_cast(data->size())); return stream.toString(); } diff --git a/src/oatpp/network/Url.cpp b/src/oatpp/network/Url.cpp index 99873e1a..90891108 100644 --- a/src/oatpp/network/Url.cpp +++ b/src/oatpp/network/Url.cpp @@ -34,7 +34,7 @@ oatpp::String Url::Parser::parseScheme(oatpp::parser::Caret& caret) { v_buff_size size = caret.getPosition() - pos0; if(size > 0) { std::unique_ptr buff(new v_char8[size]); - std::memcpy(buff.get(), &caret.getData()[pos0], size); + std::memcpy(buff.get(), &caret.getData()[pos0], static_cast(size)); utils::String::lowerCase_ASCII(buff.get(), size); return oatpp::String(reinterpret_cast(buff.get()), size); } @@ -52,7 +52,7 @@ Url::Authority Url::Parser::parseAuthority(oatpp::parser::Caret& caret) { v_buff_size portPos = -1; while (pos < caret.getDataSize()) { - v_char8 a = data[pos]; + v_char8 a = static_cast(data[pos]); if(a == '@') { atPos = pos; pos ++; diff --git a/src/oatpp/network/tcp/client/ConnectionProvider.cpp b/src/oatpp/network/tcp/client/ConnectionProvider.cpp index 951fb680..4117fd0e 100644 --- a/src/oatpp/network/tcp/client/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/client/ConnectionProvider.cpp @@ -123,7 +123,7 @@ provider::ResourceHandle ConnectionProvider::get() { if(clientHandle >= 0) { - if(connect(clientHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0) { + if(connect(clientHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0) { break; } else { err = errno; @@ -282,7 +282,7 @@ oatpp::async::CoroutineStarterForResultai_addr, static_cast(m_currentResult->ai_addrlen)); + auto res = connect(m_clientHandle, m_currentResult->ai_addr, static_cast(m_currentResult->ai_addrlen)); #if defined(WIN32) || defined(_WIN32) diff --git a/src/oatpp/network/tcp/server/ConnectionProvider.cpp b/src/oatpp/network/tcp/server/ConnectionProvider.cpp index bc3c877b..2b22ec45 100644 --- a/src/oatpp/network/tcp/server/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/server/ConnectionProvider.cpp @@ -280,7 +280,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ "Warning. Failed to set %s for accepting socket: %s", "SO_REUSEADDR", strerror(errno)); } - if (bind(serverHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0 && + if (bind(serverHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0 && listen(serverHandle, 10000) == 0) { break; diff --git a/src/oatpp/parser/json/Beautifier.cpp b/src/oatpp/parser/json/Beautifier.cpp index cd0110d9..b6808ede 100644 --- a/src/oatpp/parser/json/Beautifier.cpp +++ b/src/oatpp/parser/json/Beautifier.cpp @@ -39,9 +39,9 @@ Beautifier::Beautifier(ConsistentOutputStream* outputStream, const oatpp::String {} void Beautifier::writeIndent(ConsistentOutputStream* outputStream) { - outputStream->writeSimple(m_newLine->data(), m_newLine->size()); + outputStream->writeSimple(m_newLine->data(), static_cast(m_newLine->size())); for(v_int32 i = 0; i < m_level; i ++ ) { - outputStream->writeSimple(m_indent->data(), m_indent->size()); + outputStream->writeSimple(m_indent->data(), static_cast(m_indent->size())); } } @@ -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(data)) [i]; + v_char8 c = static_cast((reinterpret_cast(data)) [i]); if(m_isCharEscaped) { m_isCharEscaped = false; diff --git a/src/oatpp/parser/json/Utils.cpp b/src/oatpp/parser/json/Utils.cpp index d5648f01..0ca78a87 100644 --- a/src/oatpp/parser/json/Utils.cpp +++ b/src/oatpp/parser/json/Utils.cpp @@ -34,7 +34,7 @@ v_buff_size Utils::calcEscapedStringSize(const char* data, v_buff_size size, v_b v_buff_size i = 0; safeSize = size; while (i < size) { - v_char8 a = data[i]; + v_char8 a = static_cast(data[i]); if(a < 32) { i ++; @@ -102,7 +102,7 @@ v_buff_size Utils::calcUnescapedStringSize(const char* data, v_buff_size size, v v_buff_size i = 0; while (i < size) { - v_char8 a = data[i]; + v_char8 a = static_cast(data[i]); if(a == '\\'){ if(i + 1 == size){ @@ -111,7 +111,7 @@ v_buff_size Utils::calcUnescapedStringSize(const char* data, v_buff_size size, v return 0; } - v_char8 b = data[i + 1]; + v_char8 b = static_cast(data[i + 1]); if(b == '"' || b == '\\' || b == '/' || b == 'b' || b == 'f' || b == 'n' || b == 'r' || b == 't'){ result += 1; @@ -160,7 +160,7 @@ v_buff_size Utils::calcUnescapedStringSize(const char* data, v_buff_size size, v } if(low >= 0xDC00 && low <= 0xDFFF){ - v_uint32 bigCode = encoding::Unicode::utf16SurrogatePairToCode(code, low); + v_uint32 bigCode = static_cast(encoding::Unicode::utf16SurrogatePairToCode(static_cast(code), static_cast(low))); i += 12; result += encoding::Unicode::getUtf8CharSequenceLengthForCode(bigCode); } else { @@ -205,16 +205,16 @@ v_buff_size Utils::escapeUtf8Char(const char* sequence, p_char8 buffer){ oatpp::encoding::Unicode::codeToUtf16SurrogatePair(code, high, low); buffer[0] = '\\'; buffer[1] = 'u'; - oatpp::encoding::Hex::writeUInt16(high, &buffer[2]); + oatpp::encoding::Hex::writeUInt16(static_cast(high), &buffer[2]); buffer[6] = '\\'; buffer[7] = 'u'; - oatpp::encoding::Hex::writeUInt16(low, &buffer[8]); + oatpp::encoding::Hex::writeUInt16(static_cast(low), &buffer[8]); return 12; } else { buffer[0] = '\\'; buffer[1] = 'u'; buffer[2] = '+'; - oatpp::encoding::Hex::writeUInt32(code, &buffer[2]); + oatpp::encoding::Hex::writeUInt32(static_cast(code), &buffer[2]); return 11; } } @@ -232,7 +232,7 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f { v_buff_size i = 0; while (i < safeSize) { - v_char8 a = data[i]; + v_char8 a = static_cast(data[i]); if (a < 32) { switch (a) { @@ -267,13 +267,13 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f resultData[pos + 1] = '/'; pos += 2; } else { - resultData[pos] = data[i]; + resultData[pos] = static_cast(data[i]); pos++; } break; default: - resultData[pos] = data[i]; + resultData[pos] = static_cast(data[i]); pos++; break; @@ -285,7 +285,7 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f v_buff_size charSize = oatpp::encoding::Unicode::getUtf8CharSequenceLength(a); if (charSize != 0) { if (!(flags & FLAG_ESCAPE_UTF8CHAR)) { - std::memcpy(reinterpret_cast(&resultData[pos]), reinterpret_cast(const_cast(&data[i])), charSize); + std::memcpy(reinterpret_cast(&resultData[pos]), reinterpret_cast(const_cast(&data[i])), static_cast(charSize)); pos += charSize; } else { @@ -295,7 +295,7 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f } else { // invalid char - resultData[pos] = data[i]; + resultData[pos] = static_cast(data[i]); i++; pos++; } @@ -318,10 +318,10 @@ void Utils::unescapeStringToBuffer(const char* data, v_buff_size size, p_char8 r v_buff_size pos = 0; while (i < size) { - v_char8 a = data[i]; + v_char8 a = static_cast(data[i]); if(a == '\\'){ - v_char8 b = data[i + 1]; + v_char8 b = static_cast(data[i + 1]); if(b != 'u'){ switch (b) { case '"': resultData[pos] = '"'; pos ++; break; @@ -340,7 +340,7 @@ void Utils::unescapeStringToBuffer(const char* data, v_buff_size size, p_char8 r v_uint32 code; encoding::Hex::readUInt32(&data[i + 3], code); i += 11; - pos += encoding::Unicode::decodeUtf8Char(code, &resultData[pos]); + pos += encoding::Unicode::decodeUtf8Char(static_cast(code), &resultData[pos]); } else { v_uint16 code; @@ -349,8 +349,8 @@ void Utils::unescapeStringToBuffer(const char* data, v_buff_size size, p_char8 r if(code >= 0xD800 && code <= 0xDBFF){ v_uint16 low; encoding::Hex::readUInt16(&data[i + 8], low); - v_uint32 bigCode = encoding::Unicode::utf16SurrogatePairToCode(code, low); - pos += encoding::Unicode::decodeUtf8Char(bigCode, &resultData[pos]); + v_uint32 bigCode = static_cast(encoding::Unicode::utf16SurrogatePairToCode(static_cast(code), static_cast(low))); + pos += encoding::Unicode::decodeUtf8Char(static_cast(bigCode), &resultData[pos]); i += 12; } else { pos += encoding::Unicode::decodeUtf8Char(code, &resultData[pos]); @@ -377,7 +377,7 @@ oatpp::String Utils::unescapeString(const char* data, v_buff_size size, v_int64& } auto result = String(unescapedSize); if(unescapedSize == size) { - std::memcpy(reinterpret_cast(const_cast(result->data())), data, size); + std::memcpy(reinterpret_cast(const_cast(result->data())), data, static_cast(size)); } else { unescapeStringToBuffer(data, size, reinterpret_cast(const_cast(result->data()))); } @@ -392,9 +392,9 @@ std::string Utils::unescapeStringToStdString(const char* data, v_buff_size size, return ""; } std::string result; - result.resize(unescapedSize); + result.resize(static_cast(unescapedSize)); if(unescapedSize == size) { - std::memcpy(reinterpret_cast(const_cast(result.data())), data, size); + std::memcpy(reinterpret_cast(const_cast(result.data())), data, static_cast(size)); } else { unescapeStringToBuffer(data, size, reinterpret_cast(const_cast(result.data()))); } @@ -412,7 +412,7 @@ const char* Utils::preparseString(ParsingCaret& caret, v_buff_size& size){ v_buff_size length = caret.getDataSize(); while (pos < length) { - v_char8 a = data[pos]; + v_char8 a = static_cast(data[pos]); if(a == '"'){ size = pos - pos0; return &data[pos0]; diff --git a/src/oatpp/parser/json/mapping/Deserializer.cpp b/src/oatpp/parser/json/mapping/Deserializer.cpp index 68fc2314..9c6c1c67 100644 --- a/src/oatpp/parser/json/mapping/Deserializer.cpp +++ b/src/oatpp/parser/json/mapping/Deserializer.cpp @@ -32,7 +32,7 @@ Deserializer::Deserializer(const std::shared_ptr& config) : m_config(config) { - m_methods.resize(data::mapping::type::ClassId::getClassCount(), nullptr); + m_methods.resize(static_cast(data::mapping::type::ClassId::getClassCount()), nullptr); setDeserializerMethod(data::mapping::type::__class::String::CLASS_ID, &Deserializer::deserializeString); setDeserializerMethod(data::mapping::type::__class::Any::CLASS_ID, &Deserializer::deserializeAny); @@ -66,7 +66,7 @@ Deserializer::Deserializer(const std::shared_ptr& config) } void Deserializer::setDeserializerMethod(const data::mapping::type::ClassId& classId, DeserializerMethod method) { - const v_uint32 id = classId.id; + const v_uint32 id = static_cast(classId.id); if(id >= m_methods.size()) { m_methods.resize(id + 1, nullptr); } @@ -83,7 +83,7 @@ void Deserializer::skipScope(oatpp::parser::Caret& caret, v_char8 charOpen, v_ch bool isInString = false; while(pos < size){ - v_char8 a = data[pos]; + v_char8 a = static_cast(data[pos]); if(a == charOpen){ if(!isInString){ scopeCounter ++; @@ -113,7 +113,7 @@ void Deserializer::skipString(oatpp::parser::Caret& caret){ v_buff_size pos = caret.getPosition(); v_int32 scopeCounter = 0; while(pos < size){ - v_char8 a = data[pos]; + v_char8 a = static_cast(data[pos]); if(a == '"'){ scopeCounter ++; if(scopeCounter == 2) { @@ -132,7 +132,7 @@ void Deserializer::skipToken(oatpp::parser::Caret& caret){ v_buff_size size = caret.getDataSize(); v_buff_size pos = caret.getPosition(); while(pos < size){ - v_char8 a = data[pos]; + v_char8 a = static_cast(data[pos]); if(a == ' ' || a == '\t' || a == '\n' || a == '\r' || a == '\b' || a == '\f' || a == '}' || a == ',' || a == ']') { caret.setPosition(pos); @@ -225,7 +225,7 @@ const data::mapping::type::Type* Deserializer::guessNumberType(oatpp::parser::Ca const data::mapping::type::Type* Deserializer::guessType(oatpp::parser::Caret& caret) { { parser::Caret::StateSaveGuard stateGuard(caret); - v_char8 c = *caret.getCurrData(); + v_char8 c = static_cast(*caret.getCurrData()); switch (c) { case '"': return String::Class::getType(); @@ -494,7 +494,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser:: } oatpp::Void Deserializer::deserialize(parser::Caret& caret, const Type* const type) { - auto id = type->classId.id; + v_uint32 id = static_cast(type->classId.id); auto& method = m_methods[id]; if(method) { return (*method)(this, caret, type); diff --git a/src/oatpp/parser/json/mapping/Serializer.cpp b/src/oatpp/parser/json/mapping/Serializer.cpp index 525e2319..a4e638af 100644 --- a/src/oatpp/parser/json/mapping/Serializer.cpp +++ b/src/oatpp/parser/json/mapping/Serializer.cpp @@ -33,7 +33,7 @@ Serializer::Serializer(const std::shared_ptr& config) : m_config(config) { - m_methods.resize(data::mapping::type::ClassId::getClassCount(), nullptr); + m_methods.resize(static_cast(data::mapping::type::ClassId::getClassCount()), nullptr); setSerializerMethod(data::mapping::type::__class::String::CLASS_ID, &Serializer::serializeString); setSerializerMethod(data::mapping::type::__class::Any::CLASS_ID, &Serializer::serializeAny); @@ -67,7 +67,7 @@ Serializer::Serializer(const std::shared_ptr& config) } void Serializer::setSerializerMethod(const data::mapping::type::ClassId& classId, SerializerMethod method) { - const v_uint32 id = classId.id; + const v_uint32 id = static_cast(classId.id); if(id >= m_methods.size()) { m_methods.resize(id + 1, nullptr); } @@ -93,7 +93,7 @@ void Serializer::serializeString(Serializer* serializer, auto str = static_cast(polymorph.get()); - serializeString(stream, str->data(), str->size(), serializer->m_config->escapeFlags); + serializeString(stream, str->data(), static_cast(str->size()), serializer->m_config->escapeFlags); } @@ -202,7 +202,7 @@ void Serializer::serializeMap(Serializer* serializer, (first) ? first = false : stream->writeSimple(",", 1); const auto& untypedKey = iterator->getKey(); const auto& key = oatpp::String(std::static_pointer_cast(untypedKey.getPtr())); - serializeString(stream, key->data(), key->size(), serializer->m_config->escapeFlags); + serializeString(stream, key->data(), static_cast(key->size()), serializer->m_config->escapeFlags); stream->writeSimple(":", 1); serializer->serialize(stream, value); } @@ -245,7 +245,7 @@ void Serializer::serializeObject(Serializer* serializer, if (value || config->includeNullFields || (field->info.required && config->alwaysIncludeRequired)) { (first) ? first = false : stream->writeSimple(",", 1); - serializeString(stream, field->name, std::strlen(field->name), serializer->m_config->escapeFlags); + serializeString(stream, field->name, static_cast(std::strlen(field->name)), serializer->m_config->escapeFlags); stream->writeSimple(":", 1); serializer->serialize(stream, value); } @@ -259,7 +259,7 @@ void Serializer::serializeObject(Serializer* serializer, void Serializer::serialize(data::stream::ConsistentOutputStream* stream, const oatpp::Void& polymorph) { - auto id = polymorph.getValueType()->classId.id; + v_uint32 id = static_cast(polymorph.getValueType()->classId.id); auto& method = m_methods[id]; if(method) { (*method)(this, stream, polymorph); diff --git a/src/oatpp/web/mime/multipart/PartList.cpp b/src/oatpp/web/mime/multipart/PartList.cpp index 16fe4b5c..2b8ee70b 100644 --- a/src/oatpp/web/mime/multipart/PartList.cpp +++ b/src/oatpp/web/mime/multipart/PartList.cpp @@ -94,7 +94,7 @@ const std::list>& PartList::getAllParts() { } v_int64 PartList::count() { - return m_parts.size(); + return static_cast(m_parts.size()); } }}}} diff --git a/src/oatpp/web/mime/multipart/StatefulParser.cpp b/src/oatpp/web/mime/multipart/StatefulParser.cpp index 13f80d2f..87602699 100644 --- a/src/oatpp/web/mime/multipart/StatefulParser.cpp +++ b/src/oatpp/web/mime/multipart/StatefulParser.cpp @@ -144,14 +144,14 @@ StatefulParser::ListenerCall StatefulParser::parseNext_Boundary(data::buffer::In auto size = inlineData.bytesLeft; auto sampleData = m_nextBoundarySample->data(); - v_io_size sampleSize = m_nextBoundarySample->size(); + v_io_size sampleSize = static_cast(m_nextBoundarySample->size()); if (m_currPartIndex == 0) { sampleData = m_firstBoundarySample->data(); - sampleSize = m_firstBoundarySample->size(); + sampleSize = static_cast(m_firstBoundarySample->size()); } else { sampleData = m_nextBoundarySample->data(); - sampleSize = m_nextBoundarySample->size(); + sampleSize = static_cast(m_nextBoundarySample->size()); } v_io_size checkSize = sampleSize - m_currBoundaryCharIndex; diff --git a/src/oatpp/web/protocol/http/Http.cpp b/src/oatpp/web/protocol/http/Http.cpp index 88bc0603..1ce93fca 100644 --- a/src/oatpp/web/protocol/http/Http.cpp +++ b/src/oatpp/web/protocol/http/Http.cpp @@ -140,7 +140,7 @@ const char* const ContentRange::UNIT_BYTES = "bytes"; oatpp::String Range::toString() const { data::stream::BufferOutputStream stream(256); - stream.writeSimple(units->data(), units->size()); + stream.writeSimple(units->data(), static_cast(units->size())); stream.writeSimple("=", 1); stream.writeAsString(start); stream.writeSimple("-", 1); @@ -185,7 +185,7 @@ Range Range::parse(const oatpp::String& str) { oatpp::String ContentRange::toString() const { data::stream::BufferOutputStream stream(256); - stream.writeSimple(units->data(), units->size()); + stream.writeSimple(units->data(), static_cast(units->size())); stream.writeSimple(" ", 1); stream.writeAsString(start); stream.writeSimple("-", 1); @@ -266,7 +266,7 @@ oatpp::data::share::StringKeyLabelCI Parser::parseHeaderNameLabel(const std::sha oatpp::parser::Caret& caret) { const char* data = caret.getData(); for(v_buff_size i = caret.getPosition(); i < caret.getDataSize(); i++) { - v_char8 a = data[i]; + v_char8 a = static_cast(data[i]); if(a == ':' || a == ' '){ oatpp::data::share::StringKeyLabelCI label(headersText, &data[caret.getPosition()], i - caret.getPosition()); caret.setPosition(i); diff --git a/src/oatpp/web/protocol/http/encoding/Chunked.cpp b/src/oatpp/web/protocol/http/encoding/Chunked.cpp index 7760609b..5acd783a 100644 --- a/src/oatpp/web/protocol/http/encoding/Chunked.cpp +++ b/src/oatpp/web/protocol/http/encoding/Chunked.cpp @@ -69,7 +69,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff stream.write("\r\n", 2, action); m_chunkHeader = stream.toString(); - dataOut.set(reinterpret_cast(const_cast(m_chunkHeader->data())), m_chunkHeader->size()); + dataOut.set(reinterpret_cast(const_cast(m_chunkHeader->data())), static_cast(m_chunkHeader->size())); m_firstChunk = false; m_writeChunkHeader = false; @@ -96,7 +96,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff stream.write("0\r\n\r\n", 5, action); m_chunkHeader = stream.toString(); - dataOut.set(reinterpret_cast(const_cast(m_chunkHeader->data())), m_chunkHeader->size()); + dataOut.set(reinterpret_cast(const_cast(m_chunkHeader->data())), static_cast(m_chunkHeader->size())); m_firstChunk = false; m_writeChunkHeader = false; diff --git a/src/oatpp/web/protocol/http/incoming/SimpleBodyDecoder.cpp b/src/oatpp/web/protocol/http/incoming/SimpleBodyDecoder.cpp index 2c3fa2bb..08c5722c 100644 --- a/src/oatpp/web/protocol/http/incoming/SimpleBodyDecoder.cpp +++ b/src/oatpp/web/protocol/http/incoming/SimpleBodyDecoder.cpp @@ -83,7 +83,7 @@ void SimpleBodyDecoder::handleExpectHeader(const Headers& headers, data::stream: auto expect = headers.getAsMemoryLabel(Header::EXPECT); if(expect == Header::Value::EXPECT_100_CONTINUE) { - auto res = connection->writeExactSizeDataSimple(RESPONSE_100_CONTINUE.data(), RESPONSE_100_CONTINUE.size()); + auto res = connection->writeExactSizeDataSimple(RESPONSE_100_CONTINUE.data(), static_cast(RESPONSE_100_CONTINUE.size())); if(res != static_cast(RESPONSE_100_CONTINUE.size())) { throw std::runtime_error("[oatpp::web::protocol::http::incoming::SimpleBodyDecoder::handleExpectHeader()]: " "Error. Unable to send 100-continue response."); @@ -97,7 +97,7 @@ oatpp::async::CoroutineStarter SimpleBodyDecoder::handleExpectHeaderAsync(const { auto expect = headers.getAsMemoryLabel(Header::EXPECT); if(expect == Header::Value::EXPECT_100_CONTINUE) { - return connection->writeExactSizeDataAsync(RESPONSE_100_CONTINUE.data(), RESPONSE_100_CONTINUE.size()); + return connection->writeExactSizeDataAsync(RESPONSE_100_CONTINUE.data(), static_cast(RESPONSE_100_CONTINUE.size())); } return nullptr; } diff --git a/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp b/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp index 53cfb0b5..eb852e96 100644 --- a/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp +++ b/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp @@ -29,7 +29,7 @@ namespace oatpp { namespace web { namespace protocol { namespace http { namespac BufferBody::BufferBody(const oatpp::String &buffer, const data::share::StringKeyLabel &contentType) : m_buffer(buffer ? buffer : "") , m_contentType(contentType) - , m_inlineData(reinterpret_cast(const_cast(m_buffer->data())), m_buffer->size()) + , m_inlineData(reinterpret_cast(const_cast(m_buffer->data())), static_cast(m_buffer->size())) {} std::shared_ptr BufferBody::createShared(const oatpp::String &buffer, @@ -49,7 +49,7 @@ v_io_size BufferBody::read(void *buffer, v_buff_size count, async::Action &actio desiredToRead = count; } - std::memcpy(buffer, m_inlineData.currBufferPtr, desiredToRead); + std::memcpy(buffer, m_inlineData.currBufferPtr, static_cast(desiredToRead)); m_inlineData.inc(desiredToRead); return desiredToRead; @@ -71,7 +71,7 @@ p_char8 BufferBody::getKnownData() { } v_int64 BufferBody::getKnownSize() { - return m_buffer->size(); + return static_cast(m_buffer->size()); } }}}}} diff --git a/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp b/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp index 56e3ff63..c0a176ce 100644 --- a/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp +++ b/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp @@ -134,7 +134,7 @@ v_io_size MultipartBody::readBoundary(const std::shared_ptr& multipar boundary = "\r\n--" + multipart->getBoundary() + "\r\n"; } - readStream.reset(boundary.getPtr(), reinterpret_cast(const_cast(boundary->data())), boundary->size()); + readStream.reset(boundary.getPtr(), reinterpret_cast(const_cast(boundary->data())), static_cast(boundary->size())); } @@ -161,7 +161,7 @@ v_io_size MultipartBody::readHeaders(const std::shared_ptr& multipart http::Utils::writeHeaders(part->getHeaders(), &stream); stream.writeSimple("\r\n", 2); auto str = stream.toString(); - readStream.reset(str.getPtr(), reinterpret_cast(const_cast(str->data())), str->size()); + readStream.reset(str.getPtr(), reinterpret_cast(const_cast(str->data())), static_cast(str->size())); } diff --git a/src/oatpp/web/server/handler/AuthorizationHandler.cpp b/src/oatpp/web/server/handler/AuthorizationHandler.cpp index c6cc59f5..a3f019a0 100644 --- a/src/oatpp/web/server/handler/AuthorizationHandler.cpp +++ b/src/oatpp/web/server/handler/AuthorizationHandler.cpp @@ -64,7 +64,7 @@ std::shared_ptr BasicAuthorizationHandler::handleA if(header && header->size() > 6 && utils::String::compare(header->data(), 6, "Basic ", 6) == 0) { - oatpp::String auth = oatpp::encoding::Base64::decode(header->c_str() + 6, header->size() - 6); + oatpp::String auth = oatpp::encoding::Base64::decode(header->c_str() + 6, static_cast(header->size() - 6)); parser::Caret caret(auth); if (caret.findChar(':')) { @@ -110,7 +110,7 @@ std::shared_ptr BearerAuthorizationHandler::handleAuthoriza if(header && header->size() > 7 && utils::String::compare(header->data(), 7, "Bearer ", 7) == 0) { - oatpp::String token = oatpp::String(header->c_str() + 7, header->size() - 7); + oatpp::String token = oatpp::String(header->c_str() + 7, static_cast(header->size() - 7)); auto authResult = authorize(token); if(authResult) { @@ -135,4 +135,4 @@ std::shared_ptr BearerAuthorizationHandler::authorize(const return authObject; } -}}}} \ No newline at end of file +}}}} diff --git a/src/oatpp/web/url/mapping/Pattern.cpp b/src/oatpp/web/url/mapping/Pattern.cpp index e57831bc..4e10f8a6 100644 --- a/src/oatpp/web/url/mapping/Pattern.cpp +++ b/src/oatpp/web/url/mapping/Pattern.cpp @@ -99,17 +99,17 @@ std::shared_ptr Pattern::parse(p_char8 data, v_buff_size size){ } std::shared_ptr Pattern::parse(const char* data){ - return parse(reinterpret_cast(const_cast(data)), std::strlen(data)); + return parse(reinterpret_cast(const_cast(data)), static_cast(std::strlen(data))); } std::shared_ptr Pattern::parse(const oatpp::String& data){ - return parse(reinterpret_cast(const_cast(data->data())), data->size()); + return parse(reinterpret_cast(const_cast(data->data())), static_cast(data->size())); } v_char8 Pattern::findSysChar(oatpp::parser::Caret& caret) { auto data = caret.getData(); for (v_buff_size i = caret.getPosition(); i < caret.getDataSize(); i++) { - v_char8 a = data[i]; + v_char8 a = static_cast(data[i]); if(a == '/' || a == '?') { caret.setPosition(i); return a; @@ -136,7 +136,7 @@ bool Pattern::match(const StringKeyLabel& url, MatchMap& matchMap) { if(part->function == Part::FUNCTION_CONST){ - if(!caret.isAtText(part->text->data(), part->text->size(), true)) { + if(!caret.isAtText(part->text->data(), static_cast(part->text->size()), true)) { return false; } diff --git a/test/oatpp/core/async/LockTest.cpp b/test/oatpp/core/async/LockTest.cpp index 5e0b0a60..c8ba6927 100644 --- a/test/oatpp/core/async/LockTest.cpp +++ b/test/oatpp/core/async/LockTest.cpp @@ -49,7 +49,7 @@ public: void writeChar(char c) { std::lock_guard lock(m_mutex); - m_buffer->writeCharSimple(c); + m_buffer->writeCharSimple(static_cast(c)); } }; @@ -159,7 +159,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) { } bool checkSymbol(char symbol, const oatpp::String& str) { - return checkSymbol(symbol, str->data(), str->size()); + return checkSymbol(symbol, str->data(), static_cast(str->size())); } } diff --git a/test/oatpp/core/data/resource/InMemoryDataTest.cpp b/test/oatpp/core/data/resource/InMemoryDataTest.cpp index 07df7325..a9e711c1 100644 --- a/test/oatpp/core/data/resource/InMemoryDataTest.cpp +++ b/test/oatpp/core/data/resource/InMemoryDataTest.cpp @@ -44,7 +44,7 @@ void InMemoryDataTest::onRun() { { auto s = data.openOutputStream(); - s->writeExactSizeDataSimple(testData->data(), testData->size()); + s->writeExactSizeDataSimple(testData->data(), static_cast(testData->size())); } OATPP_ASSERT(data.getKnownSize() == static_cast(testData->size())) @@ -59,10 +59,10 @@ void InMemoryDataTest::onRun() { { auto s1 = data.openOutputStream(); - s1->writeExactSizeDataSimple(testData1->data(), testData1->size()); + s1->writeExactSizeDataSimple(testData1->data(), static_cast(testData1->size())); auto s2 = data.openOutputStream(); - s2->writeExactSizeDataSimple(testData2->data(), testData2->size()); + s2->writeExactSizeDataSimple(testData2->data(), static_cast(testData2->size())); s1.reset(); OATPP_ASSERT(data.getInMemoryData() == "data=" + testData1) @@ -79,7 +79,7 @@ void InMemoryDataTest::onRun() { { auto s1 = data.openOutputStream(); - s1->writeExactSizeDataSimple(testData->data(), testData->size()); + s1->writeExactSizeDataSimple(testData->data(), static_cast(testData->size())); } oatpp::data::stream::BufferOutputStream s; diff --git a/test/oatpp/encoding/UrlTest.cpp b/test/oatpp/encoding/UrlTest.cpp index ff6081cd..5297a3b8 100644 --- a/test/oatpp/encoding/UrlTest.cpp +++ b/test/oatpp/encoding/UrlTest.cpp @@ -37,7 +37,7 @@ void UrlTest::onRun(){ for(v_int32 i = 0; i < 100; i++) { oatpp::String buff(100); - utils::random::Random::randomBytes(reinterpret_cast(const_cast(buff->data())), buff->size()); + utils::random::Random::randomBytes(reinterpret_cast(const_cast(buff->data())), static_cast(buff->size())); auto encoded = oatpp::encoding::Url::encode(buff, config); auto decoded = oatpp::encoding::Url::decode(encoded); OATPP_ASSERT(decoded == buff); @@ -50,7 +50,7 @@ void UrlTest::onRun(){ for(v_int32 i = 0; i < 100; i++) { oatpp::String buff(100); - utils::random::Random::randomBytes(reinterpret_cast(const_cast(buff->data())), buff->size()); + utils::random::Random::randomBytes(reinterpret_cast(const_cast(buff->data())), static_cast(buff->size())); auto encoded = oatpp::encoding::Url::encode(buff, config); auto decoded = oatpp::encoding::Url::decode(encoded); OATPP_ASSERT(decoded == buff); diff --git a/test/oatpp/network/virtual_/InterfaceTest.cpp b/test/oatpp/network/virtual_/InterfaceTest.cpp index f8b19d96..a8ce0df3 100644 --- a/test/oatpp/network/virtual_/InterfaceTest.cpp +++ b/test/oatpp/network/virtual_/InterfaceTest.cpp @@ -55,7 +55,7 @@ namespace { auto submission = m_interface->connect(); auto socket = submission->getSocket(); - auto res = socket->writeExactSizeDataSimple(m_dataSample->data(), m_dataSample->size()); + auto res = socket->writeExactSizeDataSimple(m_dataSample->data(), static_cast(m_dataSample->size())); OATPP_ASSERT(res == static_cast(m_dataSample->size())); v_char8 buffer[100]; @@ -87,7 +87,7 @@ namespace { void run() { v_char8 buffer[100]; oatpp::data::stream::BufferOutputStream stream; - auto res = oatpp::data::stream::transfer(m_socket.get(), &stream, m_dataSample->size(), buffer, 100); + auto res = oatpp::data::stream::transfer(m_socket.get(), &stream, static_cast(m_dataSample->size()), buffer, 100); OATPP_ASSERT(res == static_cast(m_dataSample->size())); OATPP_ASSERT(stream.getCurrentPosition() == res); diff --git a/test/oatpp/network/virtual_/PipeTest.cpp b/test/oatpp/network/virtual_/PipeTest.cpp index 5884f9b4..af81ff3f 100644 --- a/test/oatpp/network/virtual_/PipeTest.cpp +++ b/test/oatpp/network/virtual_/PipeTest.cpp @@ -40,7 +40,7 @@ namespace { typedef oatpp::network::virtual_::Pipe Pipe; const char* DATA_CHUNK = "<0123456789/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ>"; - const v_buff_size CHUNK_SIZE = std::strlen(DATA_CHUNK); + const v_buff_size CHUNK_SIZE = static_cast(std::strlen(DATA_CHUNK)); class WriterTask : public oatpp::base::Countable { private: diff --git a/test/oatpp/web/FullAsyncTest.cpp b/test/oatpp/web/FullAsyncTest.cpp index c30e9d96..cbbb4ff8 100644 --- a/test/oatpp/web/FullAsyncTest.cpp +++ b/test/oatpp/web/FullAsyncTest.cpp @@ -217,7 +217,7 @@ void FullAsyncTest::onRun() { v_int32 numIterations = 10; oatpp::data::stream::BufferOutputStream stream; for(v_int32 j = 0; j < numIterations; j++) { - stream.writeSimple(sample->data(), sample->size()); + stream.writeSimple(sample->data(), static_cast(sample->size())); } auto data = stream.toString(); auto response = client->getChunked(sample, numIterations, connection); diff --git a/test/oatpp/web/FullTest.cpp b/test/oatpp/web/FullTest.cpp index 1d5bfa44..1d74a352 100644 --- a/test/oatpp/web/FullTest.cpp +++ b/test/oatpp/web/FullTest.cpp @@ -437,7 +437,7 @@ void FullTest::onRun() { v_int32 numIterations = 10; oatpp::data::stream::BufferOutputStream stream; for(v_int32 j = 0; j < numIterations; j++) { - stream.writeSimple(sample->data(), sample->size()); + stream.writeSimple(sample->data(), static_cast(sample->size())); } auto data = stream.toString(); auto response = client->getChunked(sample, numIterations, connection); diff --git a/test/oatpp/web/PipelineAsyncTest.cpp b/test/oatpp/web/PipelineAsyncTest.cpp index 618d5d59..a80bb6f4 100644 --- a/test/oatpp/web/PipelineAsyncTest.cpp +++ b/test/oatpp/web/PipelineAsyncTest.cpp @@ -163,11 +163,11 @@ void PipelineAsyncTest::onRun() { oatpp::data::stream::BufferOutputStream receiveStream; oatpp::data::buffer::IOBuffer ioBuffer; - oatpp::data::stream::transfer(connection.object.get(), &receiveStream, sample->size() * m_pipelineSize, ioBuffer.getData(), ioBuffer.getSize()); + oatpp::data::stream::transfer(connection.object.get(), &receiveStream, static_cast(sample->size() * static_cast(m_pipelineSize)), ioBuffer.getData(), ioBuffer.getSize()); auto result = receiveStream.toString(); - OATPP_ASSERT(result->size() == sample->size() * m_pipelineSize); + OATPP_ASSERT(result->size() == sample->size() * static_cast(m_pipelineSize)); //OATPP_ASSERT(result == wantedResult); // headers may come in different order on different OSs }); diff --git a/test/oatpp/web/PipelineTest.cpp b/test/oatpp/web/PipelineTest.cpp index 167cefc2..ec056ed2 100644 --- a/test/oatpp/web/PipelineTest.cpp +++ b/test/oatpp/web/PipelineTest.cpp @@ -161,14 +161,14 @@ void PipelineTest::onRun() { oatpp::data::stream::BufferOutputStream receiveStream; oatpp::data::buffer::IOBuffer ioBuffer; - v_io_size transferSize = sample->size() * m_pipelineSize; + v_io_size transferSize = static_cast(sample->size() * static_cast(m_pipelineSize)); OATPP_LOGD(TAG, "want to Receive %ld bytes", transferSize); oatpp::data::stream::transfer(connection.object.get(), &receiveStream, transferSize, ioBuffer.getData(), ioBuffer.getSize()); auto result = receiveStream.toString(); - OATPP_ASSERT(result->size() == sample->size() * m_pipelineSize); + OATPP_ASSERT(result->size() == sample->size() * static_cast(m_pipelineSize)); //OATPP_ASSERT(result == wantedResult); // headers may come in different order on different OSs }); diff --git a/test/oatpp/web/mime/multipart/StatefulParserTest.cpp b/test/oatpp/web/mime/multipart/StatefulParserTest.cpp index c553e33c..48099a44 100644 --- a/test/oatpp/web/mime/multipart/StatefulParserTest.cpp +++ b/test/oatpp/web/mime/multipart/StatefulParserTest.cpp @@ -68,15 +68,15 @@ namespace { void parseStepByStep(const oatpp::String& text, const oatpp::String& boundary, const std::shared_ptr& listener, - const v_int32 step) + const size_t step) { oatpp::web::mime::multipart::StatefulParser parser(boundary, listener, nullptr); - oatpp::data::stream::BufferInputStream stream(text.getPtr(), text->data(), text->size()); + oatpp::data::stream::BufferInputStream stream(text.getPtr(), text->data(), static_cast(text->size())); std::unique_ptr buffer(new v_char8[step]); v_io_size size; - while((size = stream.readSimple(buffer.get(), step)) != 0) { + while((size = stream.readSimple(buffer.get(), static_cast(step))) != 0) { oatpp::data::buffer::InlineWriteData inlineData(buffer.get(), size); while(inlineData.bytesLeft > 0 && !parser.finished()) { oatpp::async::Action action; @@ -119,7 +119,7 @@ void StatefulParserTest::onRun() { auto listener = std::make_shared(&multipart); listener->setDefaultPartReader(oatpp::web::mime::multipart::createInMemoryPartReader(128)); - parseStepByStep(text, "12345", listener, static_cast(i)); + parseStepByStep(text, "12345", listener, i); if(multipart.count() != 5) { OATPP_LOGD(TAG, "TEST_DATA_1 itearation %lu", i);