Skip to content

Commit f48742c

Browse files
committed
Get rid of C99 PRI?64 usage in source files
Amend to d5f1e72. It turns out that BerkelyDB was including inttypes.h indirectly, so we cannot fix this with just macros. Trivial commit: apply the following script to all .cpp and .h files: # Middle sed -i 's/"PRIx64"/x/g' "$1" sed -i 's/"PRIu64"/u/g' "$1" sed -i 's/"PRId64"/d/g' "$1" # Initial sed -i 's/PRIx64"/"x/g' "$1" sed -i 's/PRIu64"/"u/g' "$1" sed -i 's/PRId64"/"d/g' "$1" # Trailing sed -i 's/"PRIx64/x"/g' "$1" sed -i 's/"PRIu64/u"/g' "$1" sed -i 's/"PRId64/d"/g' "$1" After this commit, `git grep` for PRI.64 should turn up nothing except the defines in util.h.
1 parent 4fd082d commit f48742c

File tree

14 files changed

+36
-36
lines changed

14 files changed

+36
-36
lines changed

src/alert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ std::string CUnsignedAlert::ToString() const
5151
return strprintf(
5252
"CAlert(\n"
5353
" nVersion = %d\n"
54-
" nRelayUntil = %"PRId64"\n"
55-
" nExpiration = %"PRId64"\n"
54+
" nRelayUntil = %d\n"
55+
" nExpiration = %d\n"
5656
" nID = %d\n"
5757
" nCancel = %d\n"
5858
" setCancel = %s\n"

src/core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ uint256 CTxOut::GetHash() const
6464

6565
std::string CTxOut::ToString() const
6666
{
67-
return strprintf("CTxOut(nValue=%"PRId64".%08"PRId64", scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30));
67+
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30));
6868
}
6969

7070
void CTxOut::print() const

src/db.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void CDBEnv::Flush(bool fShutdown)
463463
else
464464
mi++;
465465
}
466-
LogPrint("db", "DBFlush(%s)%s ended %15"PRId64"ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart);
466+
LogPrint("db", "DBFlush(%s)%s ended %15dms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart);
467467
if (fShutdown)
468468
{
469469
char** listp;

src/init.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ bool AppInit2(boost::thread_group& threadGroup)
599599
{
600600
// try moving the database env out of the way
601601
boost::filesystem::path pathDatabase = GetDataDir() / "database";
602-
boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%"PRId64".bak", GetTime());
602+
boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%d.bak", GetTime());
603603
try {
604604
boost::filesystem::rename(pathDatabase, pathDatabaseBak);
605605
LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string());
@@ -874,7 +874,7 @@ bool AppInit2(boost::thread_group& threadGroup)
874874
LogPrintf("Shutdown requested. Exiting.\n");
875875
return false;
876876
}
877-
LogPrintf(" block index %15"PRId64"ms\n", GetTimeMillis() - nStart);
877+
LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart);
878878

879879
if (GetBoolArg("-printblockindex", false) || GetBoolArg("-printblocktree", false))
880880
{
@@ -985,7 +985,7 @@ bool AppInit2(boost::thread_group& threadGroup)
985985
}
986986

987987
LogPrintf("%s", strErrors.str());
988-
LogPrintf(" wallet %15"PRId64"ms\n", GetTimeMillis() - nStart);
988+
LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart);
989989

990990
RegisterWallet(pwalletMain);
991991

@@ -1007,7 +1007,7 @@ bool AppInit2(boost::thread_group& threadGroup)
10071007
LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height() - pindexRescan->nHeight, pindexRescan->nHeight);
10081008
nStart = GetTimeMillis();
10091009
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
1010-
LogPrintf(" rescan %15"PRId64"ms\n", GetTimeMillis() - nStart);
1010+
LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart);
10111011
pwalletMain->SetBestChain(chainActive.GetLocator());
10121012
nWalletDBUpdated++;
10131013
}
@@ -1042,7 +1042,7 @@ bool AppInit2(boost::thread_group& threadGroup)
10421042
LogPrintf("Invalid or missing peers.dat; recreating\n");
10431043
}
10441044

1045-
LogPrintf("Loaded %i addresses from peers.dat %"PRId64"ms\n",
1045+
LogPrintf("Loaded %i addresses from peers.dat %dms\n",
10461046
addrman.size(), GetTimeMillis() - nStart);
10471047

10481048
// ********************************************************* Step 11: start node

src/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
822822
// Don't accept it if it can't get into a block
823823
int64_t txMinFee = GetMinFee(tx, nSize, true, GMF_RELAY);
824824
if (fLimitFree && nFees < txMinFee)
825-
return state.DoS(0, error("AcceptToMemoryPool : not enough fees %s, %"PRId64" < %"PRId64,
825+
return state.DoS(0, error("AcceptToMemoryPool : not enough fees %s, %d < %d",
826826
hash.ToString(), nFees, txMinFee),
827827
REJECT_INSUFFICIENTFEE, "insufficient fee");
828828

@@ -851,7 +851,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
851851
}
852852

853853
if (fRejectInsaneFee && nFees > CTransaction::nMinRelayTxFee * 10000)
854-
return error("AcceptToMemoryPool: : insane fees %s, %"PRId64" > %"PRId64,
854+
return error("AcceptToMemoryPool: : insane fees %s, %d > %d",
855855
hash.ToString(),
856856
nFees, CTransaction::nMinRelayTxFee * 10000);
857857

@@ -1168,7 +1168,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
11681168

11691169
// Limit adjustment step
11701170
int64_t nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
1171-
LogPrintf(" nActualTimespan = %"PRId64" before bounds\n", nActualTimespan);
1171+
LogPrintf(" nActualTimespan = %d before bounds\n", nActualTimespan);
11721172
if (nActualTimespan < nTargetTimespan/4)
11731173
nActualTimespan = nTargetTimespan/4;
11741174
if (nActualTimespan > nTargetTimespan*4)
@@ -1185,7 +1185,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
11851185

11861186
/// debug print
11871187
LogPrintf("GetNextWorkRequired RETARGET\n");
1188-
LogPrintf("nTargetTimespan = %"PRId64" nActualTimespan = %"PRId64"\n", nTargetTimespan, nActualTimespan);
1188+
LogPrintf("nTargetTimespan = %d nActualTimespan = %d\n", nTargetTimespan, nActualTimespan);
11891189
LogPrintf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString());
11901190
LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString());
11911191

@@ -1737,7 +1737,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
17371737

17381738
if (block.vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees))
17391739
return state.DoS(100,
1740-
error("ConnectBlock() : coinbase pays too much (actual=%"PRId64" vs limit=%"PRId64")",
1740+
error("ConnectBlock() : coinbase pays too much (actual=%d vs limit=%d)",
17411741
block.vtx[0].GetValueOut(), GetBlockValue(pindex->nHeight, nFees)),
17421742
REJECT_INVALID, "bad-cb-amount");
17431743

@@ -3014,7 +3014,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
30143014
AbortNode(_("Error: system error: ") + e.what());
30153015
}
30163016
if (nLoaded > 0)
3017-
LogPrintf("Loaded %i blocks from external file in %"PRId64"ms\n", nLoaded, GetTimeMillis() - nStart);
3017+
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart);
30183018
return nLoaded > 0;
30193019
}
30203020

@@ -3804,7 +3804,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
38043804
}
38053805

38063806
if (!(sProblem.empty())) {
3807-
LogPrint("net", "pong %s %s: %s, %"PRIx64" expected, %"PRIx64" received, %"PRIszu" bytes\n",
3807+
LogPrint("net", "pong %s %s: %s, %x expected, %x received, %"PRIszu" bytes\n",
38083808
pfrom->addr.ToString(),
38093809
pfrom->cleanSubVer,
38103810
sProblem,

src/miner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
319319

320320
nLastBlockTx = nBlockTx;
321321
nLastBlockSize = nBlockSize;
322-
LogPrintf("CreateNewBlock(): total size %"PRIu64"\n", nBlockSize);
322+
LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize);
323323

324324
pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees);
325325
pblocktemplate->vTxFees[0] = -nFees;

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ void DumpAddresses()
12431243
CAddrDB adb;
12441244
adb.Write(addrman);
12451245

1246-
LogPrint("net", "Flushed %d addresses to peers.dat %"PRId64"ms\n",
1246+
LogPrint("net", "Flushed %d addresses to peers.dat %dms\n",
12471247
addrman.size(), GetTimeMillis() - nStart);
12481248
}
12491249

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class CNode
423423
nRequestTime = it->second;
424424
else
425425
nRequestTime = 0;
426-
LogPrint("net", "askfor %s %"PRId64" (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
426+
LogPrint("net", "askfor %s %d (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
427427

428428
// Make sure not to reuse time indexes to keep things in the same order
429429
int64_t nNow = (GetTime() - 1) * 1000000;

src/rpcnet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Value getpeerinfo(const Array& params, bool fHelp)
119119
obj.push_back(Pair("addr", stats.addrName));
120120
if (!(stats.addrLocal.empty()))
121121
obj.push_back(Pair("addrlocal", stats.addrLocal));
122-
obj.push_back(Pair("services", strprintf("%08"PRIx64, stats.nServices)));
122+
obj.push_back(Pair("services", strprintf("%08x", stats.nServices)));
123123
obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend));
124124
obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv));
125125
obj.push_back(Pair("bytessent", (boost::int64_t)stats.nSendBytes));

src/test/util_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ BOOST_AUTO_TEST_CASE(strprintf_numbers)
311311
{
312312
int64_t s64t = -9223372036854775807LL; /* signed 64 bit test value */
313313
uint64_t u64t = 18446744073709551615ULL; /* unsigned 64 bit test value */
314-
BOOST_CHECK(strprintf("%s %"PRId64" %s", B, s64t, E) == B" -9223372036854775807 "E);
315-
BOOST_CHECK(strprintf("%s %"PRIu64" %s", B, u64t, E) == B" 18446744073709551615 "E);
316-
BOOST_CHECK(strprintf("%s %"PRIx64" %s", B, u64t, E) == B" ffffffffffffffff "E);
314+
BOOST_CHECK(strprintf("%s %d %s", B, s64t, E) == B" -9223372036854775807 "E);
315+
BOOST_CHECK(strprintf("%s %u %s", B, u64t, E) == B" 18446744073709551615 "E);
316+
BOOST_CHECK(strprintf("%s %x %s", B, u64t, E) == B" ffffffffffffffff "E);
317317

318318
size_t st = 12345678; /* unsigned size_t test value */
319319
ssize_t sst = -12345678; /* signed size_t test value */

0 commit comments

Comments
 (0)