Browse Source

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.
0.10
Wladimir J. van der Laan 11 years ago
parent
commit
783b182c8f
  1. 4
      src/core.cpp
  2. 8
      src/init.cpp
  3. 22
      src/main.cpp
  4. 2
      src/miner.cpp
  5. 2
      src/rpcmisc.cpp
  6. 2
      src/rpcprotocol.cpp
  7. 12
      src/test/util_tests.cpp
  8. 12
      src/util.h
  9. 2
      src/wallet.cpp
  10. 2
      src/walletdb.cpp

4
src/core.cpp

@ -140,7 +140,7 @@ double CTransaction::ComputePriority(double dPriorityInputs, unsigned int nTxSiz
std::string CTransaction::ToString() const std::string CTransaction::ToString() const
{ {
std::string str; std::string str;
str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%"PRIszu", vout.size=%"PRIszu", nLockTime=%u)\n", str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
GetHash().ToString().substr(0,10), GetHash().ToString().substr(0,10),
nVersion, nVersion,
vin.size(), vin.size(),
@ -269,7 +269,7 @@ uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMer
void CBlock::print() const void CBlock::print() const
{ {
LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu")\n", LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
GetHash().ToString(), GetHash().ToString(),
nVersion, nVersion,
hashPrevBlock.ToString(), hashPrevBlock.ToString(),

8
src/init.cpp

@ -1078,12 +1078,12 @@ bool AppInit2(boost::thread_group& threadGroup)
RandAddSeedPerfmon(); RandAddSeedPerfmon();
//// debug print //// debug print
LogPrintf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size()); LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
LogPrintf("nBestHeight = %d\n", chainActive.Height()); LogPrintf("nBestHeight = %d\n", chainActive.Height());
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0); LogPrintf("setKeyPool.size() = %u\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapWallet.size() : 0); LogPrintf("mapWallet.size() = %u\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0); LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
#endif #endif
StartNode(threadGroup); StartNode(threadGroup);

22
src/main.cpp

@ -432,7 +432,7 @@ bool AddOrphanTx(const CTransaction& tx)
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash);
LogPrint("mempool", "stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString(), LogPrint("mempool", "stored orphan tx %s (mapsz %u)\n", hash.ToString(),
mapOrphanTransactions.size()); mapOrphanTransactions.size());
return true; return true;
} }
@ -3044,7 +3044,7 @@ void PrintBlockTree()
// print item // print item
CBlock block; CBlock block;
ReadBlockFromDisk(block, pindex); ReadBlockFromDisk(block, pindex);
LogPrintf("%d (blk%05u.dat:0x%x) %s tx %"PRIszu"\n", LogPrintf("%d (blk%05u.dat:0x%x) %s tx %u\n",
pindex->nHeight, pindex->nHeight,
pindex->GetBlockPos().nFile, pindex->GetBlockPos().nPos, pindex->GetBlockPos().nFile, pindex->GetBlockPos().nPos,
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", block.GetBlockTime()), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", block.GetBlockTime()),
@ -3371,7 +3371,7 @@ void static ProcessGetData(CNode* pfrom)
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
{ {
RandAddSeedPerfmon(); RandAddSeedPerfmon();
LogPrint("net", "received: %s (%"PRIszu" bytes)\n", strCommand, vRecv.size()); LogPrint("net", "received: %s (%u bytes)\n", strCommand, vRecv.size());
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{ {
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
@ -3515,7 +3515,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vAddr.size() > 1000) if (vAddr.size() > 1000)
{ {
Misbehaving(pfrom->GetId(), 20); Misbehaving(pfrom->GetId(), 20);
return error("message addr size() = %"PRIszu"", vAddr.size()); return error("message addr size() = %u", vAddr.size());
} }
// Store the new addresses // Store the new addresses
@ -3578,7 +3578,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vInv.size() > MAX_INV_SZ) if (vInv.size() > MAX_INV_SZ)
{ {
Misbehaving(pfrom->GetId(), 20); Misbehaving(pfrom->GetId(), 20);
return error("message inv size() = %"PRIszu"", vInv.size()); return error("message inv size() = %u", vInv.size());
} }
LOCK(cs_main); LOCK(cs_main);
@ -3617,11 +3617,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vInv.size() > MAX_INV_SZ) if (vInv.size() > MAX_INV_SZ)
{ {
Misbehaving(pfrom->GetId(), 20); Misbehaving(pfrom->GetId(), 20);
return error("message getdata size() = %"PRIszu"", vInv.size()); return error("message getdata size() = %u", vInv.size());
} }
if (fDebug || (vInv.size() != 1)) if (fDebug || (vInv.size() != 1))
LogPrint("net", "received getdata (%"PRIszu" invsz)\n", vInv.size()); LogPrint("net", "received getdata (%u invsz)\n", vInv.size());
if ((fDebug && vInv.size() > 0) || (vInv.size() == 1)) if ((fDebug && vInv.size() > 0) || (vInv.size() == 1))
LogPrint("net", "received getdata for: %s\n", vInv[0].ToString()); LogPrint("net", "received getdata for: %s\n", vInv[0].ToString());
@ -3729,7 +3729,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
vEraseQueue.push_back(inv.hash); vEraseQueue.push_back(inv.hash);
LogPrint("mempool", "AcceptToMemoryPool: %s %s : accepted %s (poolsz %"PRIszu")\n", LogPrint("mempool", "AcceptToMemoryPool: %s %s : accepted %s (poolsz %u)\n",
pfrom->addr.ToString(), pfrom->cleanSubVer, pfrom->addr.ToString(), pfrom->cleanSubVer,
tx.GetHash().ToString(), tx.GetHash().ToString(),
mempool.mapTx.size()); mempool.mapTx.size());
@ -3914,7 +3914,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
} }
if (!(sProblem.empty())) { if (!(sProblem.empty())) {
LogPrint("net", "pong %s %s: %s, %x expected, %x received, %"PRIszu" bytes\n", LogPrint("net", "pong %s %s: %s, %x expected, %x received, %u bytes\n",
pfrom->addr.ToString(), pfrom->addr.ToString(),
pfrom->cleanSubVer, pfrom->cleanSubVer,
sProblem, sProblem,
@ -4049,7 +4049,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
bool ProcessMessages(CNode* pfrom) bool ProcessMessages(CNode* pfrom)
{ {
//if (fDebug) //if (fDebug)
// LogPrintf("ProcessMessages(%"PRIszu" messages)\n", pfrom->vRecvMsg.size()); // LogPrintf("ProcessMessages(%u messages)\n", pfrom->vRecvMsg.size());
// //
// Message format // Message format
@ -4077,7 +4077,7 @@ bool ProcessMessages(CNode* pfrom)
CNetMessage& msg = *it; CNetMessage& msg = *it;
//if (fDebug) //if (fDebug)
// LogPrintf("ProcessMessages(message %u msgsz, %"PRIszu" bytes, complete:%s)\n", // LogPrintf("ProcessMessages(message %u msgsz, %u bytes, complete:%s)\n",
// msg.hdr.nMessageSize, msg.vRecv.size(), // msg.hdr.nMessageSize, msg.vRecv.size(),
// msg.complete() ? "Y" : "N"); // msg.complete() ? "Y" : "N");

2
src/miner.cpp

@ -528,7 +528,7 @@ void static BitcoinMiner(CWallet *pwallet)
CBlock *pblock = &pblocktemplate->block; CBlock *pblock = &pblocktemplate->block;
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
LogPrintf("Running BitcoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(), LogPrintf("Running BitcoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
// //

2
src/rpcmisc.cpp

@ -187,7 +187,7 @@ CScript _createmultisig(const Array& params)
if ((int)keys.size() < nRequired) if ((int)keys.size() < nRequired)
throw runtime_error( throw runtime_error(
strprintf("not enough keys supplied " strprintf("not enough keys supplied "
"(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired)); "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired));
std::vector<CPubKey> pubkeys; std::vector<CPubKey> pubkeys;
pubkeys.resize(keys.size()); pubkeys.resize(keys.size());
for (unsigned int i = 0; i < keys.size(); i++) for (unsigned int i = 0; i < keys.size(); i++)

2
src/rpcprotocol.cpp

@ -92,7 +92,7 @@ string HTTPReply(int nStatus, const string& strMsg, bool keepalive)
"HTTP/1.1 %d %s\r\n" "HTTP/1.1 %d %s\r\n"
"Date: %s\r\n" "Date: %s\r\n"
"Connection: %s\r\n" "Connection: %s\r\n"
"Content-Length: %"PRIszu"\r\n" "Content-Length: %u\r\n"
"Content-Type: application/json\r\n" "Content-Type: application/json\r\n"
"Server: bitcoin-json-rpc/%s\r\n" "Server: bitcoin-json-rpc/%s\r\n"
"\r\n" "\r\n"

12
src/test/util_tests.cpp

@ -321,15 +321,15 @@ BOOST_AUTO_TEST_CASE(strprintf_numbers)
size_t st = 12345678; /* unsigned size_t test value */ size_t st = 12345678; /* unsigned size_t test value */
ssize_t sst = -12345678; /* signed size_t test value */ ssize_t sst = -12345678; /* signed size_t test value */
BOOST_CHECK(strprintf("%s %"PRIszd" %s", B, sst, E) == B" -12345678 "E); BOOST_CHECK(strprintf("%s %d %s", B, sst, E) == B" -12345678 "E);
BOOST_CHECK(strprintf("%s %"PRIszu" %s", B, st, E) == B" 12345678 "E); BOOST_CHECK(strprintf("%s %u %s", B, st, E) == B" 12345678 "E);
BOOST_CHECK(strprintf("%s %"PRIszx" %s", B, st, E) == B" bc614e "E); BOOST_CHECK(strprintf("%s %x %s", B, st, E) == B" bc614e "E);
ptrdiff_t pt = 87654321; /* positive ptrdiff_t test value */ ptrdiff_t pt = 87654321; /* positive ptrdiff_t test value */
ptrdiff_t spt = -87654321; /* negative ptrdiff_t test value */ ptrdiff_t spt = -87654321; /* negative ptrdiff_t test value */
BOOST_CHECK(strprintf("%s %"PRIpdd" %s", B, spt, E) == B" -87654321 "E); BOOST_CHECK(strprintf("%s %d %s", B, spt, E) == B" -87654321 "E);
BOOST_CHECK(strprintf("%s %"PRIpdu" %s", B, pt, E) == B" 87654321 "E); BOOST_CHECK(strprintf("%s %u %s", B, pt, E) == B" 87654321 "E);
BOOST_CHECK(strprintf("%s %"PRIpdx" %s", B, pt, E) == B" 5397fb1 "E); BOOST_CHECK(strprintf("%s %x %s", B, pt, E) == B" 5397fb1 "E);
} }
#undef B #undef B
#undef E #undef E

12
src/util.h

@ -44,18 +44,6 @@ static const int64_t CENT = 1000000;
#define UEND(a) ((unsigned char*)&((&(a))[1])) #define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) #define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
/* Format characters for (s)size_t, ptrdiff_t.
*
* Define these as empty as the tinyformat-based formatting system is
* type-safe, no special format characters are needed to specify sizes.
*/
#define PRIszx "x"
#define PRIszu "u"
#define PRIszd "d"
#define PRIpdx "x"
#define PRIpdu "u"
#define PRIpdd "d"
// This is needed because the foreach macro can't get over the comma in pair<t1, t2> // This is needed because the foreach macro can't get over the comma in pair<t1, t2>
#define PAIRTYPE(t1, t2) std::pair<t1, t2> #define PAIRTYPE(t1, t2) std::pair<t1, t2>

2
src/wallet.cpp

@ -1638,7 +1638,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey()))) if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
throw runtime_error("TopUpKeyPool() : writing generated key failed"); throw runtime_error("TopUpKeyPool() : writing generated key failed");
setKeyPool.insert(nEnd); setKeyPool.insert(nEnd);
LogPrintf("keypool added key %d, size=%"PRIszu"\n", nEnd, setKeyPool.size()); LogPrintf("keypool added key %d, size=%u\n", nEnd, setKeyPool.size());
} }
} }
return true; return true;

2
src/walletdb.cpp

@ -894,7 +894,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys)
LogPrintf("Salvage(aggressive) found no records in %s.\n", newFilename); LogPrintf("Salvage(aggressive) found no records in %s.\n", newFilename);
return false; return false;
} }
LogPrintf("Salvage(aggressive) found %"PRIszu" records\n", salvagedData.size()); LogPrintf("Salvage(aggressive) found %u records\n", salvagedData.size());
bool fSuccess = allOK; bool fSuccess = allOK;
Db* pdbCopy = new Db(&dbenv.dbenv, 0); Db* pdbCopy = new Db(&dbenv.dbenv, 0);

Loading…
Cancel
Save