Clean warnings Ubuntu

This commit is contained in:
Leonid Stryzhevskyi 2024-05-15 04:03:25 +03:00
parent 8dd92abc32
commit a16b92db98
20 changed files with 84 additions and 41 deletions

View File

@ -104,7 +104,7 @@ public:
m_connectionProvider->getProperty("port").toString()->c_str(),
timeout.count())
std::function<bool()> condition = [&runConditionForLambda](){
std::function<bool()> condition = [&runConditionForLambda]() noexcept {
return runConditionForLambda;
};

View File

@ -168,7 +168,7 @@ void IOEventWorker::waitEvents() {
"specialization={}",
errno, m_inEventsCount,
reinterpret_cast<v_buff_usize>(m_foreman), reinterpret_cast<v_buff_usize>(this),
m_specialization)
static_cast<v_int32>(m_specialization))
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed.");
}
@ -222,7 +222,7 @@ void IOEventWorker::waitEvents() {
OATPP_LOGe(
"[oatpp::async::worker::IOEventWorker::waitEvents()]",
"Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}",
EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization
EPOLL_CTL_DEL, errno, action.getIOEventCode(), static_cast<v_int32>(m_specialization)
)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed.");
}
@ -239,7 +239,7 @@ void IOEventWorker::waitEvents() {
OATPP_LOGe(
"[oatpp::async::worker::IOEventWorker::waitEvents()]",
"Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}",
EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization
EPOLL_CTL_DEL, errno, action.getIOEventCode(), static_cast<v_int32>(m_specialization)
)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed.");
}

View File

@ -93,6 +93,34 @@ LogMessage& LogMessage::operator << (bool value) {
return *this;
}
LogMessage& LogMessage::operator << (char value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_int32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (unsigned char value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_uint32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (short value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_int32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (unsigned short value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_uint32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (int value) {
if(writeNextChunk()) {
m_stream.writeAsString(value);

View File

@ -54,6 +54,10 @@ public:
LogMessage& operator << (const char* str);
LogMessage& operator << (bool value);
LogMessage& operator << (char value);
LogMessage& operator << (unsigned char value);
LogMessage& operator << (short value);
LogMessage& operator << (unsigned short value);
LogMessage& operator << (int value);
LogMessage& operator << (unsigned value);
LogMessage& operator << (long value);

View File

@ -193,7 +193,7 @@ BufferInputStream::BufferInputStream(const std::shared_ptr<std::string>& memoryH
{}
BufferInputStream::BufferInputStream(const oatpp::String& data, const std::shared_ptr<void>& captureData)
: BufferInputStream(data.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(data->data())), static_cast<v_buff_size>(data->size()), captureData)
: BufferInputStream(data.getPtr(), reinterpret_cast<p_char8>(data->data()), static_cast<v_buff_size>(data->size()), captureData)
{}
void BufferInputStream::reset(const std::shared_ptr<std::string>& memoryHandle,

View File

@ -32,7 +32,7 @@ data::stream::DefaultInitializedContext FIFOInputStream::DEFAULT_CONTEXT(data::s
FIFOInputStream::FIFOInputStream(v_buff_size initialSize)
: m_memoryHandle(std::make_shared<std::string>(initialSize, static_cast<char>(0)))
, m_fifo(std::make_shared<data::buffer::FIFOBuffer>(reinterpret_cast<void*>(const_cast<char*>(m_memoryHandle->data())), m_memoryHandle->size(), 0, 0, false))
, m_fifo(std::make_shared<data::buffer::FIFOBuffer>(reinterpret_cast<void*>(m_memoryHandle->data()), m_memoryHandle->size(), 0, 0, false))
, m_maxCapacity(-1) {
}
@ -87,8 +87,8 @@ void FIFOInputStream::reserveBytesUpfront(v_buff_size count) {
// ToDo: In-Memory-Resize
auto newHandle = std::make_shared<std::string>(newCapacity, static_cast<char>(0));
v_io_size oldSize = m_fifo->availableToRead();
m_fifo->read(reinterpret_cast<void*>(const_cast<char*>(newHandle->data())), oldSize);
auto newFifo = std::make_shared<data::buffer::FIFOBuffer>(reinterpret_cast<void*>(const_cast<char*>(newHandle->data())), newHandle->size(), 0, oldSize, oldSize > 0);
m_fifo->read(reinterpret_cast<void*>(newHandle->data()), oldSize);
auto newFifo = std::make_shared<data::buffer::FIFOBuffer>(reinterpret_cast<void*>(newHandle->data()), newHandle->size(), 0, oldSize, oldSize > 0);
m_memoryHandle = newHandle;
m_fifo = newFifo;
}

View File

@ -45,7 +45,7 @@ String String::loadFromFile(const char* filename) {
if (file.is_open()) {
auto result = data::type::String(file.tellg());
file.seekg(0, std::ios::beg);
file.read(const_cast<char*>(result->data()), static_cast<std::streamsize>(result->size()));
file.read(result->data(), static_cast<std::streamsize>(result->size()));
file.close();
return result;
}

View File

@ -109,8 +109,8 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp
auto result = oatpp::String(resultSize);
p_char8 bdata = reinterpret_cast<p_char8>(const_cast<void*>(data));
p_char8 resultData = reinterpret_cast<p_char8>(const_cast<char*>(result->data()));
auto bdata = reinterpret_cast<const v_char8*>(data);
auto resultData = reinterpret_cast<p_char8>(result->data());
v_buff_size pos = 0;
while (pos + 2 < size) {
@ -159,7 +159,7 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux
}
auto result = oatpp::String(resultSize);
p_char8 resultData = reinterpret_cast<p_char8>(const_cast<char*>(result->data()));
auto resultData = reinterpret_cast<p_char8>(result->data());
v_buff_size pos = 0;
while (pos + 3 < base64StrLength) {
v_char8 b0 = getAlphabetCharIndex(static_cast<v_char8>(data[pos]), auxiliaryChars);

View File

@ -225,8 +225,8 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f
if(escapedSize == size) {
return String(data, size);
}
auto result = String(escapedSize);
p_char8 resultData = reinterpret_cast<p_char8>(const_cast<char*>(result->data()));
String result(escapedSize);
auto resultData = reinterpret_cast<p_char8>(result->data());
v_buff_size pos = 0;
{
@ -375,11 +375,11 @@ oatpp::String Utils::unescapeString(const char* data, v_buff_size size, v_int64&
if(errorCode != 0){
return nullptr;
}
auto result = String(unescapedSize);
String result(unescapedSize);
if(unescapedSize == size) {
std::memcpy(reinterpret_cast<void*>(const_cast<char*>(result->data())), data, static_cast<size_t>(size));
std::memcpy(reinterpret_cast<void*>(result->data()), data, static_cast<size_t>(size));
} else {
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(const_cast<char*>(result->data())));
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(result->data()));
}
return result;
@ -394,9 +394,9 @@ std::string Utils::unescapeStringToStdString(const char* data, v_buff_size size,
std::string result;
result.resize(static_cast<size_t>(unescapedSize));
if(unescapedSize == size) {
std::memcpy(reinterpret_cast<void*>(const_cast<char*>(result.data())), data, static_cast<size_t>(size));
std::memcpy(reinterpret_cast<void*>(result.data()), data, static_cast<size_t>(size));
} else {
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(const_cast<char*>(result.data())));
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(result.data()));
}
return result;

View File

@ -124,7 +124,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::get() {
if(clientHandle >= 0) {
if(connect(clientHandle, currResult->ai_addr, static_cast<v_sock_size>(currResult->ai_addrlen)) == 0) {
if(connect(clientHandle, currResult->ai_addr, currResult->ai_addrlen) == 0) {
break;
} else {
err = errno;
@ -283,7 +283,7 @@ oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::str
Action doConnect() {
errno = 0;
auto res = connect(m_clientHandle, m_currentResult->ai_addr, static_cast<v_sock_size>(m_currentResult->ai_addrlen));
auto res = connect(m_clientHandle, m_currentResult->ai_addr, m_currentResult->ai_addrlen);
#if defined(WIN32) || defined(_WIN32)

View File

@ -285,7 +285,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
"Warning. Failed to set {} for accepting socket: {}", "SO_REUSEADDR", strerror(errno))
}
if (bind(serverHandle, currResult->ai_addr, static_cast<v_sock_size>(currResult->ai_addrlen)) == 0 &&
if (bind(serverHandle, currResult->ai_addr, currResult->ai_addrlen) == 0 &&
listen(serverHandle, 10000) == 0)
{
break;

View File

@ -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<p_char8>(const_cast<char*>(m_chunkHeader->data())), static_cast<v_buff_size>(m_chunkHeader->size()));
dataOut.set(reinterpret_cast<p_char8>(m_chunkHeader->data()), static_cast<v_buff_size>(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<p_char8>(const_cast<char*>(m_chunkHeader->data())), static_cast<v_buff_size>(m_chunkHeader->size()));
dataOut.set(reinterpret_cast<p_char8>(m_chunkHeader->data()), static_cast<v_buff_size>(m_chunkHeader->size()));
m_firstChunk = false;
m_writeChunkHeader = false;

View File

@ -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<void*>(const_cast<char*>(m_buffer->data())), static_cast<v_buff_size>(m_buffer->size()))
, m_inlineData(reinterpret_cast<void*>(m_buffer->data()), static_cast<v_buff_size>(m_buffer->size()))
{}
std::shared_ptr<BufferBody> BufferBody::createShared(const oatpp::String &buffer,
@ -67,7 +67,7 @@ void BufferBody::declareHeaders(Headers &headers) {
}
p_char8 BufferBody::getKnownData() {
return reinterpret_cast<p_char8>(const_cast<char*>(m_buffer->data()));
return reinterpret_cast<p_char8>(m_buffer->data());
}
v_int64 BufferBody::getKnownSize() {

View File

@ -135,7 +135,7 @@ v_io_size MultipartBody::readBoundary(const std::shared_ptr<Multipart>& multipar
boundary = "\r\n--" + multipart->getBoundary() + "\r\n";
}
readStream.reset(boundary.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(boundary->data())), static_cast<v_buff_size>(boundary->size()));
readStream.reset(boundary.getPtr(), reinterpret_cast<p_char8>(boundary->data()), static_cast<v_buff_size>(boundary->size()));
}
@ -162,7 +162,7 @@ v_io_size MultipartBody::readHeaders(const std::shared_ptr<Multipart>& multipart
http::Utils::writeHeaders(part->getHeaders(), &stream);
stream.writeSimple("\r\n", 2);
auto str = stream.toString();
readStream.reset(str.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(str->data())), static_cast<v_buff_size>(str->size()));
readStream.reset(str.getPtr(), reinterpret_cast<p_char8>(str->data()), static_cast<v_buff_size>(str->size()));
}

View File

@ -103,7 +103,7 @@ std::shared_ptr<Pattern> Pattern::parse(const char* data){
}
std::shared_ptr<Pattern> Pattern::parse(const oatpp::String& data){
return parse(reinterpret_cast<p_char8>(const_cast<char*>(data->data())), static_cast<v_buff_size>(data->size()));
return parse(reinterpret_cast<p_char8>(data->data()), static_cast<v_buff_size>(data->size()));
}
v_char8 Pattern::findSysChar(oatpp::utils::parser::Caret& caret) {

View File

@ -51,7 +51,7 @@ public:
{}
Action act() override {
return m_cv->wait(m_lockGuard, [this]{return m_resource->counter == 100;})
return m_cv->wait(m_lockGuard, [this]() noexcept {return m_resource->counter == 100;})
.next(yieldTo(&TestCoroutineWait::onReady));
}
@ -78,7 +78,7 @@ public:
{}
Action act() override {
return m_cv->waitFor(m_lockGuard, [this]{return m_resource->counter == 100;}, std::chrono::seconds(5))
return m_cv->waitFor(m_lockGuard, [this]() noexcept{return m_resource->counter == 100;}, std::chrono::seconds(5))
.next(yieldTo(&TestCoroutineWaitWithTimeout::onReady));
}
@ -105,7 +105,7 @@ public:
{}
Action act() override {
return m_cv->waitFor(m_lockGuard, []{return false;}, std::chrono::seconds(1))
return m_cv->waitFor(m_lockGuard, []() noexcept{return false;}, std::chrono::seconds(1))
.next(yieldTo(&TestCoroutineTimeout::onReady));
}

View File

@ -141,7 +141,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) {
for (v_buff_size j = 0; j < NUM_SYMBOLS; j++) {
if (data[i + j] != symbol) {
OATPP_LOGd("aaa", "j pos={}", static_cast<v_int64>(j))
OATPP_LOGd("aaa", "j pos={}", j)
return false;
}

View File

@ -61,11 +61,24 @@ void LogTest::onRun() {
}
{
v_int8 i8 = -8;
v_uint8 u8 = 8;
v_int16 i16 = -16;
v_uint16 u16 = 16;
v_int32 i32 = -32;
v_uint32 u32 = 32;
v_int64 i64 = -64;
v_uint64 u64 = 64;
LogMessage msg("{} {} {} {} {} {} {} {}");
msg << v_int8(-8) << v_uint8(8);
msg << v_int16(-16) << v_uint16(16);
msg << v_int32(-32) << v_uint32(32);
msg << v_int64(-64) << v_uint64(64);
msg << i8 << u8;
msg << i16 << u16;
msg << i32 << u32;
msg << i64 << u64;
OATPP_ASSERT(msg.toStdString() == "-8 8 -16 16 -32 32 -64 64")
}

View File

@ -30,8 +30,6 @@ namespace oatpp { namespace data { namespace share {
void StringTemplateTest::onRun() {
typedef oatpp::data::share::StringTemplate StringTemplate;
{
OATPP_LOGi(TAG, "Case1 ...")
StringTemplate t("{} World!", {{0, 1, "p1", nullptr}});

View File

@ -38,7 +38,7 @@ void UrlTest::onRun(){
for(v_int32 i = 0; i < 100; i++) {
oatpp::String buff(100);
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(const_cast<char*>(buff->data())), static_cast<v_buff_size>(buff->size()));
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(buff->data()), static_cast<v_buff_size>(buff->size()));
auto encoded = oatpp::encoding::Url::encode(buff, config);
auto decoded = oatpp::encoding::Url::decode(encoded);
OATPP_ASSERT(decoded == buff)
@ -51,7 +51,7 @@ void UrlTest::onRun(){
for(v_int32 i = 0; i < 100; i++) {
oatpp::String buff(100);
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(const_cast<char*>(buff->data())), static_cast<v_buff_size>(buff->size()));
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(buff->data()), static_cast<v_buff_size>(buff->size()));
auto encoded = oatpp::encoding::Url::encode(buff, config);
auto decoded = oatpp::encoding::Url::decode(encoded);
OATPP_ASSERT(decoded == buff)