From b42f9d836b4c0f7fbd4bdae1734021e2a09fdbe8 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 1 Jun 2024 15:49:26 +0200 Subject: Re-enable a lot of compiler warnings for MSVC and address the C4267 "possible loss of precision" warnings --- indra/test/io.cpp | 36 ++++++++++++++++++------------------ indra/test/llbuffer_tut.cpp | 16 ++++++++-------- indra/test/llpipeutil.cpp | 2 +- indra/test/llsdmessagereader_tut.cpp | 2 +- indra/test/llstreamtools_tut.cpp | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) (limited to 'indra/test') diff --git a/indra/test/io.cpp b/indra/test/io.cpp index 412f9ca1d2..3bb549a98a 100644 --- a/indra/test/io.cpp +++ b/indra/test/io.cpp @@ -155,7 +155,7 @@ namespace tut void buffer_object::test<1>() { const char HELLO_WORLD[] = "hello world"; - const S32 str_len = strlen(HELLO_WORLD); + const S32 str_len = static_cast(strlen(HELLO_WORLD)); LLChannelDescriptors ch = mBuffer.nextChannel(); mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len); S32 count = mBuffer.countAfter(ch.in(), NULL); @@ -170,7 +170,7 @@ namespace tut void buffer_object::test<2>() { const char HELLO_WORLD[] = "hello world"; - const S32 str_len = strlen(HELLO_WORLD); /* Flawfinder: ignore */ + const S32 str_len = static_cast(strlen(HELLO_WORLD)); /* Flawfinder: ignore */ LLChannelDescriptors ch = mBuffer.nextChannel(); mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len); mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len); @@ -249,15 +249,15 @@ namespace tut expected << "ContentLength: " << response.length() << "\r\n\r\n" << response; LLChannelDescriptors ch = mBuffer.nextChannel(); - mBuffer.append(ch.in(), (U8*)request.c_str(), request.length()); - mBuffer.append(ch.out(), (U8*)response.c_str(), response.length()); + mBuffer.append(ch.in(), (U8*)request.c_str(), static_cast(request.length())); + mBuffer.append(ch.out(), (U8*)response.c_str(), static_cast(response.length())); S32 count = mBuffer.countAfter(ch.out(), NULL); std::ostringstream header; header << "ContentLength: " << count << "\r\n\r\n"; std::string head(header.str()); - mBuffer.prepend(ch.out(), (U8*)head.c_str(), head.length()); + mBuffer.prepend(ch.out(), (U8*)head.c_str(), static_cast(head.length())); char buffer[1024]; /* Flawfinder: ignore */ - S32 len = response.size() + head.length(); + S32 len = static_cast(response.size() + head.length()); ensure_equals("same length", len, (S32)expected.str().length()); mBuffer.readAfter(ch.out(), NULL, (U8*)buffer, len); buffer[len] = '\0'; @@ -282,7 +282,7 @@ namespace tut text.append(lines[i]); } LLChannelDescriptors ch = mBuffer.nextChannel(); - mBuffer.append(ch.in(), (U8*)text.c_str(), text.length()); + mBuffer.append(ch.in(), (U8*)text.c_str(), static_cast(text.length())); const S32 BUFFER_LEN = 1024; char buf[BUFFER_LEN]; S32 len; @@ -411,7 +411,7 @@ namespace tut void bas_object::test<1>() { const char HELLO_WORLD[] = "hello world"; - const S32 str_len = strlen(HELLO_WORLD); /* Flawfinder: ignore */ + const S32 str_len = static_cast(strlen(HELLO_WORLD)); /* Flawfinder: ignore */ LLChannelDescriptors ch = mBuffer.nextChannel(); LLBufferStream str(ch, &mBuffer); mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len); @@ -431,10 +431,10 @@ namespace tut std::string ignore("ignore me"); LLChannelDescriptors ch = mBuffer.nextChannel(); LLBufferStream str(ch, &mBuffer); - mBuffer.append(ch.in(), (U8*)part1.c_str(), part1.length()); - mBuffer.append(ch.in(), (U8*)part2.c_str(), part2.length()); - mBuffer.append(ch.out(), (U8*)ignore.c_str(), ignore.length()); - mBuffer.append(ch.in(), (U8*)part3.c_str(), part3.length()); + mBuffer.append(ch.in(), (U8*)part1.c_str(), static_cast(part1.length())); + mBuffer.append(ch.in(), (U8*)part2.c_str(), static_cast(part2.length())); + mBuffer.append(ch.out(), (U8*)ignore.c_str(), static_cast(ignore.length())); + mBuffer.append(ch.in(), (U8*)part3.c_str(), static_cast(part3.length())); std::string eat; std::string my; std::string shorts; @@ -452,8 +452,8 @@ namespace tut std::string part1("junk in "); std::string part2("the trunk"); const S32 CHANNEL = 0; - mBuffer.append(CHANNEL, (U8*)part1.c_str(), part1.length()); - mBuffer.append(CHANNEL, (U8*)part2.c_str(), part2.length()); + mBuffer.append(CHANNEL, (U8*)part1.c_str(), static_cast(part1.length())); + mBuffer.append(CHANNEL, (U8*)part2.c_str(), static_cast(part2.length())); U8* last = 0; const S32 BUF_LEN = 128; char buf[BUF_LEN]; @@ -475,7 +475,7 @@ namespace tut { std::string phrase("zippity do da!"); const S32 CHANNEL = 0; - mBuffer.append(CHANNEL, (U8*)phrase.c_str(), phrase.length()); + mBuffer.append(CHANNEL, (U8*)phrase.c_str(), static_cast(phrase.length())); const S32 BUF_LEN = 128; char buf[BUF_LEN]; S32 len = 7; @@ -506,7 +506,7 @@ namespace tut const S32 BUF_LEN = 128; char buf[BUF_LEN]; S32 actual_len = BUF_LEN; - S32 expected_len = h1.size() + h2.size(); + S32 expected_len = static_cast(h1.size() + h2.size()); (void) mBuffer.readAfter(ch.out(), NULL, (U8*)buf, actual_len); ensure_equals("streamed size", actual_len, expected_len); buf[actual_len] = '\0'; @@ -728,7 +728,7 @@ namespace tut "'circuit_code': i124,'group_id': '8615c885-9cf0-bf0a-6e40-0c11462aa652','limited_to_estate': i1,'look_at': [ i0, i0, i0]," "'agent_id': '0e346d8b-4433-4d66-a6b0-fd37083abc4c','first_name': 'Kelly','start': 'url'}]}"; LLChannelDescriptors ch = mBuffer.nextChannel(); - mBuffer.append(ch.out(), (U8*)LOGIN_STREAM, strlen(LOGIN_STREAM)); /* Flawfinder: ignore */ + mBuffer.append(ch.out(), (U8*)LOGIN_STREAM, static_cast(strlen(LOGIN_STREAM))); /* Flawfinder: ignore */ ch = mBuffer.nextChannel(); LLBufferStream istr(ch, &mBuffer); LLSD data; @@ -1130,7 +1130,7 @@ namespace tut mPump->addChain(chain, NEVER_CHAIN_EXPIRY_SECS); // We need to tickle the pump a little to set up the listen() pump_loop(mPump, 0.1f); - U32 count = mPump->runningChains(); + auto count = mPump->runningChains(); ensure_equals("server chain onboard", count, 1); LL_DEBUGS() << "** Server is up." << LL_ENDL; diff --git a/indra/test/llbuffer_tut.cpp b/indra/test/llbuffer_tut.cpp index 07cb4d5aed..330a4f288f 100644 --- a/indra/test/llbuffer_tut.cpp +++ b/indra/test/llbuffer_tut.cpp @@ -128,7 +128,7 @@ namespace tut { LLBufferArray bufferArray; const char array[] = "SecondLife"; - S32 len = strlen(array); + S32 len = static_cast(strlen(array)); LLChannelDescriptors channelDescriptors = bufferArray.nextChannel(); bufferArray.append(channelDescriptors.in(), (U8*)array, len); S32 count = bufferArray.countAfter(channelDescriptors.in(), NULL); @@ -141,9 +141,9 @@ namespace tut { LLBufferArray bufferArray; const char array[] = "SecondLife"; - S32 len = strlen(array); + S32 len = static_cast(strlen(array)); const char array1[] = "LindenLabs"; - S32 len1 = strlen(array1); + S32 len1 = static_cast(strlen(array1)); std::string str(array1); str.append(array); @@ -166,9 +166,9 @@ namespace tut { LLBufferArray bufferArray; const char array[] = "SecondLife"; - S32 len = strlen(array); + S32 len = static_cast(strlen(array)); const char array1[] = "LindenLabs"; - S32 len1 = strlen(array1); + S32 len1 = static_cast(strlen(array1)); std::string str(array); str.append(array1); @@ -190,7 +190,7 @@ namespace tut { LLBufferArray bufferArray; const char array[] = "SecondLife"; - S32 len = strlen(array) + 1; + S32 len = static_cast(strlen(array)) + 1; std::string str(array); LLChannelDescriptors channelDescriptors = bufferArray.nextChannel(); bufferArray.append(channelDescriptors.in(), (U8*)array, len); @@ -208,7 +208,7 @@ namespace tut void buffer_object_t::test<10>() { const char array[] = "SecondLife is a Virtual World"; - S32 len = strlen(array); + S32 len = static_cast(strlen(array)); LLBufferArray bufferArray; bufferArray.append(0, (U8*)array, len); @@ -229,7 +229,7 @@ namespace tut void buffer_object_t::test<11>() { const char array[] = "SecondLife is a Virtual World"; - S32 len = strlen(array); + S32 len = static_cast(strlen(array)); LLBufferArray bufferArray; bufferArray.append(0, (U8*)array, len); diff --git a/indra/test/llpipeutil.cpp b/indra/test/llpipeutil.cpp index c64cf21326..1dd4bdfa3c 100644 --- a/indra/test/llpipeutil.cpp +++ b/indra/test/llpipeutil.cpp @@ -60,7 +60,7 @@ LLIOPipe::EStatus LLPipeStringInjector::process_impl( LLSD& context, LLPumpIO* pump) { - buffer->append(channels.out(), (U8*) mString.data(), mString.size()); + buffer->append(channels.out(), (U8*) mString.data(), static_cast(mString.size())); eos = true; return STATUS_DONE; } diff --git a/indra/test/llsdmessagereader_tut.cpp b/indra/test/llsdmessagereader_tut.cpp index 38c4d870cb..dd6520ea33 100644 --- a/indra/test/llsdmessagereader_tut.cpp +++ b/indra/test/llsdmessagereader_tut.cpp @@ -318,7 +318,7 @@ namespace tut inValue[1] = 1; LLSDMessageReader msg = testType(inValue); - msg.getBinaryData("block", "var", &(outValue[0]), inValue.size()); + msg.getBinaryData("block", "var", &(outValue[0]), static_cast(inValue.size())); ensure_equals("Ensure Binary", outValue, inValue); } } diff --git a/indra/test/llstreamtools_tut.cpp b/indra/test/llstreamtools_tut.cpp index 68bd5e0ec9..970afb3b02 100644 --- a/indra/test/llstreamtools_tut.cpp +++ b/indra/test/llstreamtools_tut.cpp @@ -846,7 +846,7 @@ namespace tut char buf[255] = {0}; fullread(is, buf, 255); - ensure_memory_matches("fullread: read with newlines", (void*) buf, str.size()-1, (void*) str.c_str(), str.size()-1); + ensure_memory_matches("fullread: read with newlines", (void*) buf, static_cast(str.size())-1, (void*) str.c_str(), static_cast(str.size())-1); is.clear(); is.str(str = "First Line.\nSecond Line\n"); -- cgit v1.2.3