mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
Merge pull request #828 from fhuberts/fix-Wsign-compare
Fix compiler warnings (-Wsign-compare)
This commit is contained in:
commit
104c4eb011
@ -268,7 +268,6 @@ endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
# Disable some warnings
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-Wno-sign-compare")
|
||||
add_compiler_flags(4.6 "-Wno-unused-parameter")
|
||||
|
||||
add_compiler_flags(9.1 "-Wno-pessimizing-move")
|
||||
|
@ -115,7 +115,7 @@ v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn,
|
||||
}
|
||||
|
||||
data::buffer::InlineReadData* currDataOut = &dataOut;
|
||||
if(i < m_intermediateData.size()) {
|
||||
if(i < static_cast<v_buff_size>(m_intermediateData.size())) {
|
||||
currDataOut = &m_intermediateData[i];
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
* Capture data referenced by memory label to its own memory.
|
||||
*/
|
||||
void captureToOwnMemory() const {
|
||||
if(!m_memoryHandle || m_memoryHandle->data() != reinterpret_cast<const char*>(m_data) || m_memoryHandle->size() != m_size) {
|
||||
if(!m_memoryHandle || m_memoryHandle->data() != reinterpret_cast<const char*>(m_data) || static_cast<v_buff_size>(m_memoryHandle->size()) != m_size) {
|
||||
m_memoryHandle = std::make_shared<std::string>(reinterpret_cast<const char*>(m_data), m_size);
|
||||
m_data = m_memoryHandle->data();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ StringTemplate::StringTemplate(const oatpp::String& text, std::vector<Variable>&
|
||||
, m_variables(variables)
|
||||
{
|
||||
v_buff_size prevPos = 0;
|
||||
for(v_int32 i = 0; i < m_variables.size(); i++) {
|
||||
for(size_t i = 0; i < m_variables.size(); i++) {
|
||||
const auto& var = m_variables[i];
|
||||
|
||||
if(var.posStart < prevPos) {
|
||||
|
@ -36,7 +36,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_int32 strToInt32(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_int32 result = static_cast<v_int32>(std::strtol(str->data(), &end, 10));
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == str->size());
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_uint32 strToUInt32(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_uint32 result = static_cast<v_uint32>(std::strtoul(str->data(), &end, 10));
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == str->size());
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_int64 strToInt64(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_int64 result = std::strtoll(str->data(), &end, 10);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == str->size());
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_uint64 strToUInt64(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_uint64 result = std::strtoull(str->data(), &end, 10);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == str->size());
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_float32 strToFloat32(const oatpp::String& str, bool& success) {
|
||||
char* end;
|
||||
v_float32 result = std::strtof(str->data(), &end);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == str->size());
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_float64 strToFloat64(const oatpp::String& str, bool& success) {
|
||||
char* end;
|
||||
v_float64 result = std::strtod(str->data(), &end);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == str->size());
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void SimpleBodyDecoder::handleExpectHeader(const Headers& headers, data::stream:
|
||||
auto expect = headers.getAsMemoryLabel<data::share::StringKeyLabelCI>(Header::EXPECT);
|
||||
if(expect == Header::Value::EXPECT_100_CONTINUE) {
|
||||
auto res = connection->writeExactSizeDataSimple(RESPONSE_100_CONTINUE.data(), RESPONSE_100_CONTINUE.size());
|
||||
if(res != RESPONSE_100_CONTINUE.size()) {
|
||||
if(res != static_cast<v_io_size>(RESPONSE_100_CONTINUE.size())) {
|
||||
throw std::runtime_error("[oatpp::web::protocol::http::incoming::SimpleBodyDecoder::handleExpectHeader()]: "
|
||||
"Error. Unable to send 100-continue response.");
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ void InMemoryDataTest::onRun() {
|
||||
s->writeExactSizeDataSimple(testData->data(), testData->size());
|
||||
}
|
||||
|
||||
OATPP_ASSERT(data.getKnownSize() == testData->size())
|
||||
OATPP_ASSERT(data.getKnownSize() == static_cast<v_int64>(testData->size()))
|
||||
OATPP_ASSERT(data.getInMemoryData() == testData)
|
||||
OATPP_ASSERT(data.getLocation() == nullptr)
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ void LazyStringMapTest::onRun() {
|
||||
auto s13 = all["key1"];
|
||||
auto s23 = all["key2"];
|
||||
|
||||
OATPP_ASSERT(s13.getData() == s1->data() && s13.getSize() == s1->size());
|
||||
OATPP_ASSERT(s23.getData() == s2->data() && s23.getSize() == s2->size());
|
||||
OATPP_ASSERT(s13.getData() == s1->data() && s13.getSize() == static_cast<v_buff_size>(s1->size()));
|
||||
OATPP_ASSERT(s23.getData() == s2->data() && s23.getSize() == static_cast<v_buff_size>(s2->size()));
|
||||
OATPP_ASSERT(s1.get() == s13.getMemoryHandle().get());
|
||||
OATPP_ASSERT(s2.get() == s23.getMemoryHandle().get());
|
||||
|
||||
|
@ -111,10 +111,10 @@ void BufferStreamTest::onRun() {
|
||||
|
||||
auto wholeText = stream.toString();
|
||||
|
||||
OATPP_ASSERT(wholeText->size() == fragmentsCount * 10);
|
||||
OATPP_ASSERT(wholeText->size() == static_cast<size_t>(fragmentsCount * 10));
|
||||
|
||||
v_int32 substringSize = 10;
|
||||
for(v_int32 i = 0; i < wholeText->size() - substringSize; i ++) {
|
||||
v_buff_size substringSize = 10;
|
||||
for(v_buff_size i = 0; i < static_cast<v_buff_size>(wholeText->size()) - substringSize; i ++) {
|
||||
OATPP_ASSERT(oatpp::String(&wholeText->data()[i], substringSize) == stream.getSubstring(i, substringSize));
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace {
|
||||
auto socket = submission->getSocket();
|
||||
|
||||
auto res = socket->writeExactSizeDataSimple(m_dataSample->data(), m_dataSample->size());
|
||||
OATPP_ASSERT(res == m_dataSample->size());
|
||||
OATPP_ASSERT(res == static_cast<v_io_size>(m_dataSample->size()));
|
||||
|
||||
v_char8 buffer[100];
|
||||
oatpp::data::stream::BufferOutputStream stream;
|
||||
@ -89,7 +89,7 @@ namespace {
|
||||
oatpp::data::stream::BufferOutputStream stream;
|
||||
auto res = oatpp::data::stream::transfer(m_socket.get(), &stream, m_dataSample->size(), buffer, 100);
|
||||
|
||||
OATPP_ASSERT(res == m_dataSample->size());
|
||||
OATPP_ASSERT(res == static_cast<v_io_size>(m_dataSample->size()));
|
||||
OATPP_ASSERT(stream.getCurrentPosition() == res);
|
||||
OATPP_ASSERT(stream.toString() == m_dataSample);
|
||||
|
||||
|
@ -112,17 +112,17 @@ void StatefulParserTest::onRun() {
|
||||
|
||||
oatpp::String text = TEST_DATA_1;
|
||||
|
||||
for(v_int32 i = 1; i < text->size(); i++) {
|
||||
for(size_t i = 1; i < text->size(); i++) {
|
||||
|
||||
oatpp::web::mime::multipart::PartList multipart("12345");
|
||||
|
||||
auto listener = std::make_shared<oatpp::web::mime::multipart::PartsParser>(&multipart);
|
||||
listener->setDefaultPartReader(oatpp::web::mime::multipart::createInMemoryPartReader(128));
|
||||
|
||||
parseStepByStep(text, "12345", listener, i);
|
||||
parseStepByStep(text, "12345", listener, static_cast<v_int32>(i));
|
||||
|
||||
if(multipart.count() != 5) {
|
||||
OATPP_LOGD(TAG, "TEST_DATA_1 itearation %d", i);
|
||||
OATPP_LOGD(TAG, "TEST_DATA_1 itearation %lu", i);
|
||||
}
|
||||
|
||||
OATPP_ASSERT(multipart.count() == 5);
|
||||
|
@ -62,7 +62,7 @@ void ChunkedTest::onRun() {
|
||||
|
||||
auto count = oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer, bufferSize, &decoder);
|
||||
decoded = outStream.toString();
|
||||
OATPP_ASSERT(count == encoded->size());
|
||||
OATPP_ASSERT(count == static_cast<v_io_size>(encoded->size()));
|
||||
OATPP_ASSERT(decoded == "");
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ void ChunkedTest::onRun() {
|
||||
auto count = oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer, bufferSize, &encoder);
|
||||
encoded = outStream.toString();
|
||||
|
||||
OATPP_ASSERT(count == data->size());
|
||||
OATPP_ASSERT(count == static_cast<v_io_size>(data->size()));
|
||||
OATPP_ASSERT(encoded == "5\r\nHello\r\n5\r\n Worl\r\n4\r\nd!!!\r\n0\r\n\r\n");
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ void ChunkedTest::onRun() {
|
||||
|
||||
auto count = oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer, bufferSize, &decoder);
|
||||
decoded = outStream.toString();
|
||||
OATPP_ASSERT(count == encoded->size());
|
||||
OATPP_ASSERT(count == static_cast<v_io_size>(encoded->size()));
|
||||
OATPP_LOGD(TAG, "decoded='%s'", decoded->c_str());
|
||||
OATPP_ASSERT(decoded == data);
|
||||
}
|
||||
@ -114,7 +114,7 @@ void ChunkedTest::onRun() {
|
||||
|
||||
auto count = oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer, bufferSize, &pipeline);
|
||||
auto result = outStream.toString();
|
||||
OATPP_ASSERT(count == data->size());
|
||||
OATPP_ASSERT(count == static_cast<v_io_size>(data->size()));
|
||||
OATPP_LOGD(TAG, "result='%s'", result->c_str());
|
||||
OATPP_ASSERT(result == data);
|
||||
}
|
||||
@ -122,4 +122,4 @@ void ChunkedTest::onRun() {
|
||||
|
||||
}
|
||||
|
||||
}}}}}}
|
||||
}}}}}}
|
||||
|
Loading…
Reference in New Issue
Block a user