Now that fmt plays nice with gcc let's actually use it: replace std::to_string, boost lexical_cast and a couple miscellaneous llformats with fmt. (Alchemy sync-ish)

This commit is contained in:
Router Gray
2020-05-20 14:38:30 -05:00
parent 34a7ebf53f
commit 3e78b74474
31 changed files with 92 additions and 113 deletions

View File

@@ -31,7 +31,6 @@
#include "llnamevalue.h"
#include "u64.h"
#include "llstring.h"
#include "llstringtable.h"
@@ -149,7 +148,7 @@ void LLNameValue::init(const char *name, const char *data, const char *type, con
else if (!strcmp(mStringType, "U64"))
{
mType = NVT_U64;
mNameValueReference.u64 = new U64(str_to_U64(ll_safe_string(data)));
mNameValueReference.u64 = new U64(std::stoull(data));
}
else if (!strcmp(mStringType, "VEC3"))
{
@@ -919,9 +918,7 @@ std::string LLNameValue::printData() const
break;
case NVT_U64:
{
char u64_string[U64_BUFFER_LEN]; /* Flawfinder: ignore */
U64_to_str(*mNameValueReference.u64, u64_string, sizeof(u64_string));
buffer = u64_string;
buffer = fmt::to_string(*mNameValueReference.u64);
}
break;
case NVT_VEC3:
@@ -952,11 +949,7 @@ std::ostream& operator<<(std::ostream& s, const LLNameValue &a)
s << *(a.mNameValueReference.u32);
break;
case NVT_U64:
{
char u64_string[U64_BUFFER_LEN]; /* Flawfinder: ignore */
U64_to_str(*a.mNameValueReference.u64, u64_string, sizeof(u64_string));
s << u64_string;
}
s << (*a.mNameValueReference.u64);
break;
case NVT_VEC3:
s << *(a.mNameValueReference.vec3);

View File

@@ -30,7 +30,6 @@
#include "lluuid.h"
#include "llerror.h"
#include "llmath.h"
#include "u64.h"
//number of bytes sent in each message
const U32 LL_XFER_CHUNK_SIZE = 1000;
@@ -347,12 +346,12 @@ void LLXfer::abort (S32 result_code)
if (result_code != LL_ERR_CIRCUIT_GONE)
{
gMessageSystem->newMessageFast(_PREHASH_AbortXfer);
gMessageSystem->nextBlockFast(_PREHASH_XferID);
gMessageSystem->addU64Fast(_PREHASH_ID, mID);
gMessageSystem->addS32Fast(_PREHASH_Result, result_code);
gMessageSystem->sendMessage(mRemoteHost);
gMessageSystem->newMessageFast(_PREHASH_AbortXfer);
gMessageSystem->nextBlockFast(_PREHASH_XferID);
gMessageSystem->addU64Fast(_PREHASH_ID, mID);
gMessageSystem->addS32Fast(_PREHASH_Result, result_code);
gMessageSystem->sendMessage(mRemoteHost);
}
mStatus = e_LL_XFER_ABORTED;
@@ -363,7 +362,7 @@ void LLXfer::abort (S32 result_code)
std::string LLXfer::getFileName()
{
return U64_to_str(mID);
return fmt::to_string(mID);
}
///////////////////////////////////////////////////////////

View File

@@ -35,7 +35,6 @@
#include "llerror.h"
#include "lluuid.h"
#include "u64.h"
const F32 LL_XFER_REGISTRATION_TIMEOUT = 60.0f; // timeout if a registered transfer hasn't been requested in 60 seconds
const F32 LL_PACKET_TIMEOUT = 3.0f; // packet timeout at 3 s
@@ -543,11 +542,10 @@ void LLXferManager::processReceiveData (LLMessageSystem *mesgsys, void ** /*user
if (fdata_size < 0 ||
fdata_size > BUF_SIZE)
{
char U64_BUF[MAX_STRING]; /* Flawfinder : ignore */
LL_WARNS("Xfer") << "Received invalid xfer data size of " << fdata_size
<< " in packet number " << packetnum
<< " from " << mesgsys->getSender()
<< " for xfer id: " << U64_to_str(id, U64_BUF, sizeof(U64_BUF))
<< " for xfer id: " << fmt::to_string(id)
<< LL_ENDL;
return;
}
@@ -556,10 +554,9 @@ void LLXferManager::processReceiveData (LLMessageSystem *mesgsys, void ** /*user
xferp = findXferByID(id, mReceiveList);
if (!xferp)
{
char U64_BUF[MAX_STRING]; /* Flawfinder : ignore */
LL_WARNS("Xfer") << "received xfer data from " << mesgsys->getSender()
<< " for non-existent xfer id: "
<< U64_to_str(id, U64_BUF, sizeof(U64_BUF)) << LL_ENDL;
<< fmt::to_string(id) << LL_ENDL;
return;
}
@@ -765,8 +762,7 @@ void LLXferManager::processFileRequest (LLMessageSystem *mesgsys, void ** /*user
mesgsys->getBOOL("XferID", "UseBigPackets", b_use_big_packets);
mesgsys->getU64Fast(_PREHASH_XferID, _PREHASH_ID, id);
char U64_BUF[MAX_STRING]; /* Flawfinder : ignore */
LL_INFOS("Xfer") << "xfer request id: " << U64_to_str(id, U64_BUF, sizeof(U64_BUF))
LL_INFOS("Xfer") << "xfer request id: " << fmt::to_string(id)
<< " to " << mesgsys->getSender() << LL_ENDL;
mesgsys->getStringFast(_PREHASH_XferID, _PREHASH_Filename, local_filename);
@@ -890,9 +886,8 @@ void LLXferManager::processFileRequest (LLMessageSystem *mesgsys, void ** /*user
}
else
{ // no uuid or filename - use the ID sent
char U64_BUF[MAX_STRING]; /* Flawfinder : ignore */
LL_INFOS("Xfer") << "starting memory transfer: "
<< U64_to_str(id, U64_BUF, sizeof(U64_BUF)) << " to "
<< fmt::to_string(id) << " to "
<< mesgsys->getSender() << LL_ENDL;
xferp = findXferByID(id, mSendList);
@@ -903,7 +898,7 @@ void LLXferManager::processFileRequest (LLMessageSystem *mesgsys, void ** /*user
}
else
{
LL_INFOS("Xfer") << "Warning: xfer ID " << U64_BUF << " not found." << LL_ENDL;
LL_INFOS("Xfer") << "Warning: xfer ID " << fmt::to_string(id) << " not found." << LL_ENDL;
result = LL_ERR_FILE_NOT_FOUND;
}
}
@@ -937,12 +932,12 @@ void LLXferManager::processFileRequest (LLMessageSystem *mesgsys, void ** /*user
{ // Not many transfers in progress already, so start immediately
xferp->sendNextPacket();
changeNumActiveXfers(xferp->mRemoteHost,1);
LL_DEBUGS("Xfer") << "Starting xfer ID " << U64_to_str(id) << " immediately" << LL_ENDL;
LL_DEBUGS("Xfer") << "Starting xfer ID " << fmt::to_string(id) << " immediately" << LL_ENDL;
}
else if (mHardLimitOutgoingXfersPerCircuit == 0 ||
(host_statusp->mNumActive + host_statusp->mNumPending) < mHardLimitOutgoingXfersPerCircuit)
{ // Must close the file handle and wait for earlier ones to complete
LL_INFOS("Xfer") << " queueing xfer request id " << U64_to_str(id) << ", "
LL_INFOS("Xfer") << " queueing xfer request id " << fmt::to_string(id) << ", "
<< host_statusp->mNumActive << " active and "
<< host_statusp->mNumPending << " pending ahead of this one"
<< LL_ENDL;
@@ -983,13 +978,13 @@ void LLXferManager::processFileRequest (LLMessageSystem *mesgsys, void ** /*user
}
else
{
LL_WARNS("Xfer") << "LLXferManager::processFileRequest() - no LLHostStatus found for id " << U64_to_str(id)
LL_WARNS("Xfer") << "LLXferManager::processFileRequest() - no LLHostStatus found for id " << fmt::to_string(id)
<< " host " << xferp->mRemoteHost << LL_ENDL;
}
}
else
{
LL_WARNS("Xfer") << "LLXferManager::processFileRequest() - no xfer found for id " << U64_to_str(id) << LL_ENDL;
LL_WARNS("Xfer") << "LLXferManager::processFileRequest() - no xfer found for id " << fmt::to_string(id) << LL_ENDL;
}
}
@@ -1113,7 +1108,7 @@ void LLXferManager::retransmitUnackedPackets()
{
if (xferp->reopenFileHandle())
{
LL_WARNS("Xfer") << "Error re-opening file handle for xfer ID " << U64_to_str(xferp->mID)
LL_WARNS("Xfer") << "Error re-opening file handle for xfer ID " << fmt::to_string(xferp->mID)
<< " to host " << xferp->mRemoteHost << LL_ENDL;
xferp->abort(LL_ERR_CANNOT_OPEN_FILE);
iter = mSendList.erase(iter);
@@ -1122,7 +1117,7 @@ void LLXferManager::retransmitUnackedPackets()
}
else
{ // No error re-opening the file, send the first packet
LL_DEBUGS("Xfer") << "Moving pending xfer ID " << U64_to_str(xferp->mID) << " to active" << LL_ENDL;
LL_DEBUGS("Xfer") << "Moving pending xfer ID " << fmt::to_string(xferp->mID) << " to active" << LL_ENDL;
xferp->sendNextPacket();
changeNumActiveXfers(xferp->mRemoteHost,1);
}
@@ -1136,7 +1131,7 @@ void LLXferManager::retransmitUnackedPackets()
// so we don't blow through bandwidth.
//
while (mXferAckQueue.size())
while (!mXferAckQueue.empty())
{
if (mAckThrottle.checkOverflow(1000.0f*8.0f))
{

View File

@@ -73,7 +73,6 @@
#include "llxfermanager.h"
#include "timing.h"
#include "llquaternion.h"
#include "u64.h"
#include "v3dmath.h"
#include "v3math.h"
#include "v4math.h"
@@ -2600,54 +2599,54 @@ void LLMessageSystem::summarizeLogs(std::ostream& str)
// Incoming
str << buffer << std::endl << "Incoming:" << std::endl;
tmp_str = U64_to_str(mTotalBytesIn);
tmp_str = fmt::to_string(mTotalBytesIn);
buffer = llformat( "Total bytes received: %20s (%5.2f kbits per second)", tmp_str.c_str(), ((F32)mTotalBytesIn * 0.008f) / run_time);
str << buffer << std::endl;
tmp_str = U64_to_str(mPacketsIn);
tmp_str = fmt::to_string(mPacketsIn);
buffer = llformat( "Total packets received: %20s (%5.2f packets per second)", tmp_str.c_str(), ((F32) mPacketsIn / run_time));
str << buffer << std::endl;
buffer = llformat( "Average packet size: %20.0f bytes", (F32)mTotalBytesIn / (F32)mPacketsIn);
str << buffer << std::endl;
tmp_str = U64_to_str(mReliablePacketsIn);
tmp_str = fmt::to_string(mReliablePacketsIn);
buffer = llformat( "Total reliable packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mReliablePacketsIn)/((F32) mPacketsIn + 1));
str << buffer << std::endl;
tmp_str = U64_to_str(mCompressedPacketsIn);
tmp_str = fmt::to_string(mCompressedPacketsIn);
buffer = llformat( "Total compressed packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mCompressedPacketsIn)/((F32) mPacketsIn + 1));
str << buffer << std::endl;
S64 savings = mUncompressedBytesIn - mCompressedBytesIn;
tmp_str = U64_to_str(savings);
tmp_str = fmt::to_string(savings);
buffer = llformat( "Total compression savings: %20s bytes", tmp_str.c_str());
str << buffer << std::endl;
tmp_str = U64_to_str(savings/(mCompressedPacketsIn +1));
tmp_str = fmt::to_string(savings/(mCompressedPacketsIn +1));
buffer = llformat( "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mUncompressedBytesIn)/((F32) mCompressedBytesIn+1));
str << buffer << std::endl;
tmp_str = U64_to_str(savings/(mPacketsIn+1));
tmp_str = fmt::to_string(savings/(mPacketsIn+1));
buffer = llformat( "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mTotalBytesIn + (F32) savings)/((F32) mTotalBytesIn + 1.f));
// Outgoing
str << buffer << std::endl << std::endl << "Outgoing:" << std::endl;
tmp_str = U64_to_str(mTotalBytesOut);
tmp_str = fmt::to_string(mTotalBytesOut);
buffer = llformat( "Total bytes sent: %20s (%5.2f kbits per second)", tmp_str.c_str(), ((F32)mTotalBytesOut * 0.008f) / run_time );
str << buffer << std::endl;
tmp_str = U64_to_str(mPacketsOut);
tmp_str = fmt::to_string(mPacketsOut);
buffer = llformat( "Total packets sent: %20s (%5.2f packets per second)", tmp_str.c_str(), ((F32)mPacketsOut / run_time));
str << buffer << std::endl;
buffer = llformat( "Average packet size: %20.0f bytes", (F32)mTotalBytesOut / (F32)mPacketsOut);
str << buffer << std::endl;
tmp_str = U64_to_str(mReliablePacketsOut);
tmp_str = fmt::to_string(mReliablePacketsOut);
buffer = llformat( "Total reliable packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mReliablePacketsOut)/((F32) mPacketsOut + 1));
str << buffer << std::endl;
tmp_str = U64_to_str(mCompressedPacketsOut);
tmp_str = fmt::to_string(mCompressedPacketsOut);
buffer = llformat( "Total compressed packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mCompressedPacketsOut)/((F32) mPacketsOut + 1));
str << buffer << std::endl;
savings = mUncompressedBytesOut - mCompressedBytesOut;
tmp_str = U64_to_str(savings);
tmp_str = fmt::to_string(savings);
buffer = llformat( "Total compression savings: %20s bytes", tmp_str.c_str());
str << buffer << std::endl;
tmp_str = U64_to_str(savings/(mCompressedPacketsOut +1));
tmp_str = fmt::to_string(savings/(mCompressedPacketsOut +1));
buffer = llformat( "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mUncompressedBytesOut)/((F32) mCompressedBytesOut+1));
str << buffer << std::endl;
tmp_str = U64_to_str(savings/(mPacketsOut+1));
tmp_str = fmt::to_string(savings/(mPacketsOut+1));
buffer = llformat( "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mTotalBytesOut + (F32) savings)/((F32) mTotalBytesOut + 1.f));
str << buffer << std::endl << std::endl;
buffer = llformat( "SendPacket failures: %20d", mSendPacketFailureCount);