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/llmessage/llassetstorage.cpp | 2 +- indra/llmessage/llavatarnamecache.cpp | 2 +- indra/llmessage/llcachename.cpp | 8 ++++---- indra/llmessage/llcircuit.cpp | 4 ++-- indra/llmessage/llcoproceduremanager.cpp | 2 +- indra/llmessage/lldatapacker.cpp | 4 ++-- indra/llmessage/llfiltersd2xmlrpc.cpp | 4 ++-- indra/llmessage/lliohttpserver.cpp | 2 +- indra/llmessage/lliosocket.cpp | 2 +- indra/llmessage/llmail.cpp | 2 +- indra/llmessage/llproxy.cpp | 2 +- indra/llmessage/llpumpio.cpp | 2 +- indra/llmessage/llsdmessagereader.cpp | 8 ++++---- indra/llmessage/lltemplatemessagedispatcher.cpp | 4 ++-- indra/llmessage/llxfer_file.cpp | 2 +- indra/llmessage/message.cpp | 4 ++-- 16 files changed, 27 insertions(+), 27 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index 13fda24e62..b3390451a2 100644 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -1125,7 +1125,7 @@ S32 LLAssetStorage::getNumPending(LLAssetStorage::ERequestType rt) const S32 num_pending = -1; if (requests) { - num_pending = requests->size(); + num_pending = static_cast(requests->size()); } return num_pending; } diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index a0cd6f93c1..ff7c2f8387 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -240,7 +240,7 @@ void LLAvatarNameCache::handleAvNameCacheSuccess(const LLSD &data, const LLSD &h // Same logic as error response case const LLSD& unresolved_agents = data["bad_ids"]; - S32 num_unresolved = unresolved_agents.size(); + auto num_unresolved = unresolved_agents.size(); if (num_unresolved > 0) { LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " << num_unresolved << " unresolved ids; " diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 6fb21957e0..63ac46722a 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -562,13 +562,13 @@ std::string LLCacheName::buildLegacyName(const std::string& complete_name) { //boost::regexp was showing up in the crashreporter, so doing //painfully manual parsing using substr. LF - S32 open_paren = complete_name.rfind(" ("); - S32 close_paren = complete_name.rfind(')'); + auto open_paren = complete_name.rfind(" ("); + auto close_paren = complete_name.rfind(')'); if (open_paren != std::string::npos && close_paren == complete_name.length()-1) { - S32 length = close_paren - open_paren - 2; + auto length = close_paren - open_paren - 2; std::string legacy_name = complete_name.substr(open_paren+2, length); if (legacy_name.length() > 0) @@ -577,7 +577,7 @@ std::string LLCacheName::buildLegacyName(const std::string& complete_name) LLStringUtil::toUpper(cap_letter); legacy_name = cap_letter + legacy_name.substr(1); - S32 separator = legacy_name.find('.'); + auto separator = legacy_name.find('.'); if (separator != std::string::npos) { diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp index fa206d9282..bf22f3d3f0 100644 --- a/indra/llmessage/llcircuit.cpp +++ b/indra/llmessage/llcircuit.cpp @@ -781,8 +781,8 @@ void LLCircuitData::checkPacketInID(TPACKETID id, bool receive_resent) void LLCircuit::updateWatchDogTimers(LLMessageSystem *msgsys) { F64Seconds cur_time = LLMessageSystem::getMessageTimeSeconds(); - S32 count = mPingSet.size(); - S32 cur = 0; + size_t count = mPingSet.size(); + size_t cur = 0; // Only process each circuit once at most, stop processing if no circuits while((cur < count) && !mPingSet.empty()) diff --git a/indra/llmessage/llcoproceduremanager.cpp b/indra/llmessage/llcoproceduremanager.cpp index 959cfb2762..263670bdac 100644 --- a/indra/llmessage/llcoproceduremanager.cpp +++ b/indra/llmessage/llcoproceduremanager.cpp @@ -87,7 +87,7 @@ public: /// inline S32 count() const { - return countPending() + countActive(); + return static_cast(countPending() + countActive()); } void close(); diff --git a/indra/llmessage/lldatapacker.cpp b/indra/llmessage/lldatapacker.cpp index 134f34aafa..e911150787 100644 --- a/indra/llmessage/lldatapacker.cpp +++ b/indra/llmessage/lldatapacker.cpp @@ -237,7 +237,7 @@ bool LLDataPacker::unpackUUIDs(LLUUID *values, S32 count, const char *name) bool LLDataPackerBinaryBuffer::packString(const std::string& value, const char *name) { - S32 length = value.length()+1; + S32 length = static_cast(value.length()) + 1; if (!verifyLength(length, name)) { @@ -740,7 +740,7 @@ bool LLDataPackerAsciiBuffer::packString(const std::string& value, const char *n } else { - numCopied = value.length() + 1; /*Flawfinder: ignore*/ + numCopied = static_cast(value.length()) + 1; /*Flawfinder: ignore*/ } // snprintf returns number of bytes that would have been written diff --git a/indra/llmessage/llfiltersd2xmlrpc.cpp b/indra/llmessage/llfiltersd2xmlrpc.cpp index df78652361..84b56d54bf 100644 --- a/indra/llmessage/llfiltersd2xmlrpc.cpp +++ b/indra/llmessage/llfiltersd2xmlrpc.cpp @@ -274,12 +274,12 @@ void LLFilterSD2XMLRPC::streamOut(std::ostream& ostr, const LLSD& sd) if(!buffer.empty()) { // *TODO: convert to LLBase64 - int b64_buffer_length = apr_base64_encode_len(buffer.size()); + int b64_buffer_length = apr_base64_encode_len(static_cast(buffer.size())); char* b64_buffer = new char[b64_buffer_length]; b64_buffer_length = apr_base64_encode_binary( b64_buffer, &buffer[0], - buffer.size()); + static_cast(buffer.size())); ostr.write(b64_buffer, b64_buffer_length - 1); delete[] b64_buffer; } diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index 9791a20743..e562f09844 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -494,7 +494,7 @@ LLIOPipe::EStatus LLHTTPResponseHeader::process_impl( LLChangeChannel change(channels.in(), channels.out()); std::for_each(buffer->beginSegment(), buffer->endSegment(), change); std::string header = ostr.str(); - buffer->prepend(channels.out(), (U8*)header.c_str(), header.size()); + buffer->prepend(channels.out(), (U8*)header.c_str(), static_cast(header.size())); PUMP_DEBUG; return STATUS_DONE; } diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index a14d10fe5f..f2192acee0 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -346,7 +346,7 @@ LLIOPipe::EStatus LLIOSocketReader::process_impl( PUMP_DEBUG; len = READ_BUFFER_SIZE; status = apr_socket_recv(mSource->getSocket(), read_buf, &len); - buffer->append(channels.out(), (U8*)read_buf, len); + buffer->append(channels.out(), (U8*)read_buf, static_cast(len)); } while((APR_SUCCESS == status) && (READ_BUFFER_SIZE == len)); LL_DEBUGS() << "socket read status: " << status << LL_ENDL; LLIOPipe::EStatus rv = STATUS_OK; diff --git a/indra/llmessage/llmail.cpp b/indra/llmessage/llmail.cpp index ca027d7675..9e10a356db 100644 --- a/indra/llmessage/llmail.cpp +++ b/indra/llmessage/llmail.cpp @@ -273,7 +273,7 @@ bool LLMail::send( std::string good_string = "\n..\n"; while (1) { - int index = message.find(bad_string); + auto index = message.find(bad_string); if (index == std::string::npos) break; message.replace(index, bad_string.size(), good_string); } diff --git a/indra/llmessage/llproxy.cpp b/indra/llmessage/llproxy.cpp index 3e1e5daa02..864e68998c 100644 --- a/indra/llmessage/llproxy.cpp +++ b/indra/llmessage/llproxy.cpp @@ -123,7 +123,7 @@ S32 LLProxy::proxyHandshake(LLHost proxy) // The server has requested a username/password combination std::string socks_username(getSocksUser()); std::string socks_password(getSocksPwd()); - U32 request_size = socks_username.size() + socks_password.size() + 3; + U32 request_size = static_cast(socks_username.size() + socks_password.size() + 3); char * password_auth = new char[request_size]; password_auth[0] = 0x01; password_auth[1] = (char)(socks_username.size()); diff --git a/indra/llmessage/llpumpio.cpp b/indra/llmessage/llpumpio.cpp index d3b75cf86b..e1cd70b216 100644 --- a/indra/llmessage/llpumpio.cpp +++ b/indra/llmessage/llpumpio.cpp @@ -818,7 +818,7 @@ void LLPumpIO::rebuildPollset() running_chains_t::iterator run_end = mRunningChains.end(); for(; run_it != run_end; ++run_it) { - size += (*run_it).mDescriptors.size(); + size += static_cast((*run_it).mDescriptors.size()); } //LL_DEBUGS() << "found " << size << " descriptors." << LL_ENDL; if(size) diff --git a/indra/llmessage/llsdmessagereader.cpp b/indra/llmessage/llsdmessagereader.cpp index 8be6158d82..6ade7c0dad 100644 --- a/indra/llmessage/llsdmessagereader.cpp +++ b/indra/llmessage/llsdmessagereader.cpp @@ -242,7 +242,7 @@ void LLSDMessageReader::getString(const char *block, const char *var, return; } std::string data = getLLSD(mMessage, block, var, blocknum); - S32 data_size = data.size(); + auto data_size = data.size(); if (data_size >= buffer_size) { data_size = buffer_size - 1; @@ -261,7 +261,7 @@ void LLSDMessageReader::getString(const char *block, const char *var, //virtual S32 LLSDMessageReader::getNumberOfBlocks(const char *blockname) { - return mMessage[blockname].size(); + return static_cast(mMessage[blockname].size()); } S32 getElementSize(const LLSD& llsd) @@ -276,7 +276,7 @@ S32 getElementSize(const LLSD& llsd) case LLSD::TypeReal: return sizeof(F64); case LLSD::TypeString: - return llsd.size(); + return static_cast(llsd.size()); case LLSD::TypeUUID: return sizeof(LLUUID); case LLSD::TypeDate: @@ -286,7 +286,7 @@ S32 getElementSize(const LLSD& llsd) case LLSD::TypeBinary: { std::vector data = llsd; - return data.size() * sizeof(U8); + return static_cast(data.size() * sizeof(U8)); } case LLSD::TypeMap: case LLSD::TypeArray: diff --git a/indra/llmessage/lltemplatemessagedispatcher.cpp b/indra/llmessage/lltemplatemessagedispatcher.cpp index 267c201705..0e709d6c75 100644 --- a/indra/llmessage/lltemplatemessagedispatcher.cpp +++ b/indra/llmessage/lltemplatemessagedispatcher.cpp @@ -44,7 +44,7 @@ void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name, LLHTTPNode::ResponsePtr responsep) { std::vector data = message["body"]["binary-template-data"].asBinary(); - U32 size = data.size(); + auto size = data.size(); if(size == 0) { return; @@ -53,7 +53,7 @@ void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name, LLHost host; host = gMessageSystem->getSender(); - bool validate_message = mTemplateMessageReader.validateMessage(&(data[0]), data.size(), host, true); + bool validate_message = mTemplateMessageReader.validateMessage(&(data[0]), static_cast(size), host, true); if (validate_message) { diff --git a/indra/llmessage/llxfer_file.cpp b/indra/llmessage/llxfer_file.cpp index ad15d5969b..71b910297b 100644 --- a/indra/llmessage/llxfer_file.cpp +++ b/indra/llmessage/llxfer_file.cpp @@ -317,7 +317,7 @@ S32 LLXfer_File::flush() if (mFp) { - S32 write_size = fwrite(mBuffer,1,mBufferLength,mFp); + S32 write_size = static_cast(fwrite(mBuffer,1,mBufferLength,mFp)); if (write_size != mBufferLength) { LL_WARNS("Xfer") << "Non-matching write size, requested " << mBufferLength diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index e705c36ff8..cfa5178fc6 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -2172,7 +2172,7 @@ S32 LLMessageSystem::sendError( if (LLMessageConfig::getMessageFlavor(ERROR_MESSAGE_NAME) == LLMessageConfig::TEMPLATE_FLAVOR) { - S32 msg_size = temp.size() + mMessageBuilder->getMessageSize(); + S32 msg_size = static_cast(temp.size()) + mMessageBuilder->getMessageSize(); if(msg_size >= ETHERNET_MTU_BYTES) { pack_data = false; @@ -2180,7 +2180,7 @@ S32 LLMessageSystem::sendError( } if(pack_data) { - addBinaryData("Data", (void*)temp.c_str(), temp.size()); + addBinaryData("Data", (void*)temp.c_str(), static_cast(temp.size())); } else { -- cgit v1.2.3