Skip to content

Commit 783b182

Browse files
committed
Remove dummy PRIszX macros for formatting
Size specifiers are no longer needed now that we use typesafe tinyformat for string formatting, instead of the system's sprintf. No functional changes. This continues the work in #3735.
1 parent b733288 commit 783b182

File tree

10 files changed

+28
-40
lines changed

10 files changed

+28
-40
lines changed

src/core.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ double CTransaction::ComputePriority(double dPriorityInputs, unsigned int nTxSiz
140140
std::string CTransaction::ToString() const
141141
{
142142
std::string str;
143-
str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%"PRIszu", vout.size=%"PRIszu", nLockTime=%u)\n",
143+
str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
144144
GetHash().ToString().substr(0,10),
145145
nVersion,
146146
vin.size(),
@@ -269,7 +269,7 @@ uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMer
269269

270270
void CBlock::print() const
271271
{
272-
LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu")\n",
272+
LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
273273
GetHash().ToString(),
274274
nVersion,
275275
hashPrevBlock.ToString(),

src/init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,12 +1078,12 @@ bool AppInit2(boost::thread_group& threadGroup)
10781078
RandAddSeedPerfmon();
10791079

10801080
//// debug print
1081-
LogPrintf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size());
1081+
LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
10821082
LogPrintf("nBestHeight = %d\n", chainActive.Height());
10831083
#ifdef ENABLE_WALLET
1084-
LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
1085-
LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
1086-
LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
1084+
LogPrintf("setKeyPool.size() = %u\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
1085+
LogPrintf("mapWallet.size() = %u\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
1086+
LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
10871087
#endif
10881088

10891089
StartNode(threadGroup);

src/main.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ bool AddOrphanTx(const CTransaction& tx)
432432
BOOST_FOREACH(const CTxIn& txin, tx.vin)
433433
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash);
434434

435-
LogPrint("mempool", "stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString(),
435+
LogPrint("mempool", "stored orphan tx %s (mapsz %u)\n", hash.ToString(),
436436
mapOrphanTransactions.size());
437437
return true;
438438
}
@@ -3044,7 +3044,7 @@ void PrintBlockTree()
30443044
// print item
30453045
CBlock block;
30463046
ReadBlockFromDisk(block, pindex);
3047-
LogPrintf("%d (blk%05u.dat:0x%x) %s tx %"PRIszu"\n",
3047+
LogPrintf("%d (blk%05u.dat:0x%x) %s tx %u\n",
30483048
pindex->nHeight,
30493049
pindex->GetBlockPos().nFile, pindex->GetBlockPos().nPos,
30503050
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", block.GetBlockTime()),
@@ -3371,7 +3371,7 @@ void static ProcessGetData(CNode* pfrom)
33713371
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
33723372
{
33733373
RandAddSeedPerfmon();
3374-
LogPrint("net", "received: %s (%"PRIszu" bytes)\n", strCommand, vRecv.size());
3374+
LogPrint("net", "received: %s (%u bytes)\n", strCommand, vRecv.size());
33753375
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
33763376
{
33773377
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
@@ -3515,7 +3515,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
35153515
if (vAddr.size() > 1000)
35163516
{
35173517
Misbehaving(pfrom->GetId(), 20);
3518-
return error("message addr size() = %"PRIszu"", vAddr.size());
3518+
return error("message addr size() = %u", vAddr.size());
35193519
}
35203520

35213521
// Store the new addresses
@@ -3578,7 +3578,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
35783578
if (vInv.size() > MAX_INV_SZ)
35793579
{
35803580
Misbehaving(pfrom->GetId(), 20);
3581-
return error("message inv size() = %"PRIszu"", vInv.size());
3581+
return error("message inv size() = %u", vInv.size());
35823582
}
35833583

35843584
LOCK(cs_main);
@@ -3617,11 +3617,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
36173617
if (vInv.size() > MAX_INV_SZ)
36183618
{
36193619
Misbehaving(pfrom->GetId(), 20);
3620-
return error("message getdata size() = %"PRIszu"", vInv.size());
3620+
return error("message getdata size() = %u", vInv.size());
36213621
}
36223622

36233623
if (fDebug || (vInv.size() != 1))
3624-
LogPrint("net", "received getdata (%"PRIszu" invsz)\n", vInv.size());
3624+
LogPrint("net", "received getdata (%u invsz)\n", vInv.size());
36253625

36263626
if ((fDebug && vInv.size() > 0) || (vInv.size() == 1))
36273627
LogPrint("net", "received getdata for: %s\n", vInv[0].ToString());
@@ -3729,7 +3729,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
37293729
vEraseQueue.push_back(inv.hash);
37303730

37313731

3732-
LogPrint("mempool", "AcceptToMemoryPool: %s %s : accepted %s (poolsz %"PRIszu")\n",
3732+
LogPrint("mempool", "AcceptToMemoryPool: %s %s : accepted %s (poolsz %u)\n",
37333733
pfrom->addr.ToString(), pfrom->cleanSubVer,
37343734
tx.GetHash().ToString(),
37353735
mempool.mapTx.size());
@@ -3914,7 +3914,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
39143914
}
39153915

39163916
if (!(sProblem.empty())) {
3917-
LogPrint("net", "pong %s %s: %s, %x expected, %x received, %"PRIszu" bytes\n",
3917+
LogPrint("net", "pong %s %s: %s, %x expected, %x received, %u bytes\n",
39183918
pfrom->addr.ToString(),
39193919
pfrom->cleanSubVer,
39203920
sProblem,
@@ -4049,7 +4049,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
40494049
bool ProcessMessages(CNode* pfrom)
40504050
{
40514051
//if (fDebug)
4052-
// LogPrintf("ProcessMessages(%"PRIszu" messages)\n", pfrom->vRecvMsg.size());
4052+
// LogPrintf("ProcessMessages(%u messages)\n", pfrom->vRecvMsg.size());
40534053

40544054
//
40554055
// Message format
@@ -4077,7 +4077,7 @@ bool ProcessMessages(CNode* pfrom)
40774077
CNetMessage& msg = *it;
40784078

40794079
//if (fDebug)
4080-
// LogPrintf("ProcessMessages(message %u msgsz, %"PRIszu" bytes, complete:%s)\n",
4080+
// LogPrintf("ProcessMessages(message %u msgsz, %u bytes, complete:%s)\n",
40814081
// msg.hdr.nMessageSize, msg.vRecv.size(),
40824082
// msg.complete() ? "Y" : "N");
40834083

src/miner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ void static BitcoinMiner(CWallet *pwallet)
528528
CBlock *pblock = &pblocktemplate->block;
529529
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
530530

531-
LogPrintf("Running BitcoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
531+
LogPrintf("Running BitcoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
532532
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
533533

534534
//

src/rpcmisc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ CScript _createmultisig(const Array& params)
187187
if ((int)keys.size() < nRequired)
188188
throw runtime_error(
189189
strprintf("not enough keys supplied "
190-
"(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired));
190+
"(got %u keys, but need at least %d to redeem)", keys.size(), nRequired));
191191
std::vector<CPubKey> pubkeys;
192192
pubkeys.resize(keys.size());
193193
for (unsigned int i = 0; i < keys.size(); i++)

src/rpcprotocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ string HTTPReply(int nStatus, const string& strMsg, bool keepalive)
9292
"HTTP/1.1 %d %s\r\n"
9393
"Date: %s\r\n"
9494
"Connection: %s\r\n"
95-
"Content-Length: %"PRIszu"\r\n"
95+
"Content-Length: %u\r\n"
9696
"Content-Type: application/json\r\n"
9797
"Server: bitcoin-json-rpc/%s\r\n"
9898
"\r\n"

src/test/util_tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,15 @@ BOOST_AUTO_TEST_CASE(strprintf_numbers)
321321

322322
size_t st = 12345678; /* unsigned size_t test value */
323323
ssize_t sst = -12345678; /* signed size_t test value */
324-
BOOST_CHECK(strprintf("%s %"PRIszd" %s", B, sst, E) == B" -12345678 "E);
325-
BOOST_CHECK(strprintf("%s %"PRIszu" %s", B, st, E) == B" 12345678 "E);
326-
BOOST_CHECK(strprintf("%s %"PRIszx" %s", B, st, E) == B" bc614e "E);
324+
BOOST_CHECK(strprintf("%s %d %s", B, sst, E) == B" -12345678 "E);
325+
BOOST_CHECK(strprintf("%s %u %s", B, st, E) == B" 12345678 "E);
326+
BOOST_CHECK(strprintf("%s %x %s", B, st, E) == B" bc614e "E);
327327

328328
ptrdiff_t pt = 87654321; /* positive ptrdiff_t test value */
329329
ptrdiff_t spt = -87654321; /* negative ptrdiff_t test value */
330-
BOOST_CHECK(strprintf("%s %"PRIpdd" %s", B, spt, E) == B" -87654321 "E);
331-
BOOST_CHECK(strprintf("%s %"PRIpdu" %s", B, pt, E) == B" 87654321 "E);
332-
BOOST_CHECK(strprintf("%s %"PRIpdx" %s", B, pt, E) == B" 5397fb1 "E);
330+
BOOST_CHECK(strprintf("%s %d %s", B, spt, E) == B" -87654321 "E);
331+
BOOST_CHECK(strprintf("%s %u %s", B, pt, E) == B" 87654321 "E);
332+
BOOST_CHECK(strprintf("%s %x %s", B, pt, E) == B" 5397fb1 "E);
333333
}
334334
#undef B
335335
#undef E

src/util.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,6 @@ static const int64_t CENT = 1000000;
4444
#define UEND(a) ((unsigned char*)&((&(a))[1]))
4545
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
4646

47-
/* Format characters for (s)size_t, ptrdiff_t.
48-
*
49-
* Define these as empty as the tinyformat-based formatting system is
50-
* type-safe, no special format characters are needed to specify sizes.
51-
*/
52-
#define PRIszx "x"
53-
#define PRIszu "u"
54-
#define PRIszd "d"
55-
#define PRIpdx "x"
56-
#define PRIpdu "u"
57-
#define PRIpdd "d"
58-
5947
// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
6048
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
6149

src/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
16381638
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
16391639
throw runtime_error("TopUpKeyPool() : writing generated key failed");
16401640
setKeyPool.insert(nEnd);
1641-
LogPrintf("keypool added key %d, size=%"PRIszu"\n", nEnd, setKeyPool.size());
1641+
LogPrintf("keypool added key %d, size=%u\n", nEnd, setKeyPool.size());
16421642
}
16431643
}
16441644
return true;

src/walletdb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys)
894894
LogPrintf("Salvage(aggressive) found no records in %s.\n", newFilename);
895895
return false;
896896
}
897-
LogPrintf("Salvage(aggressive) found %"PRIszu" records\n", salvagedData.size());
897+
LogPrintf("Salvage(aggressive) found %u records\n", salvagedData.size());
898898

899899
bool fSuccess = allOK;
900900
Db* pdbCopy = new Db(&dbenv.dbenv, 0);

0 commit comments

Comments
 (0)