Browse Source

fix -Wformat warnings all over the source

miguelfreitas
Philip Kaufmann 12 years ago committed by Wladimir J. van der Laan
parent
commit
d210f4f5b8
  1. 2
      src/bitcoinrpc.cpp
  2. 8
      src/init.cpp
  3. 2
      src/irc.cpp
  4. 34
      src/main.cpp
  5. 6
      src/main.h
  6. 2
      src/net.cpp
  7. 2
      src/rpcwallet.cpp
  8. 2
      src/util.cpp
  9. 6
      src/wallet.cpp

2
src/bitcoinrpc.cpp

@ -345,7 +345,7 @@ static 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: %d\r\n" "Content-Length: %"PRIszu"\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"

8
src/init.cpp

@ -767,11 +767,11 @@ bool AppInit2()
RandAddSeedPerfmon(); RandAddSeedPerfmon();
//// debug print //// debug print
printf("mapBlockIndex.size() = %d\n", mapBlockIndex.size()); printf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size());
printf("nBestHeight = %d\n", nBestHeight); printf("nBestHeight = %d\n", nBestHeight);
printf("setKeyPool.size() = %d\n", pwalletMain->setKeyPool.size()); printf("setKeyPool.size() = %"PRIszu"\n", pwalletMain->setKeyPool.size());
printf("mapWallet.size() = %d\n", pwalletMain->mapWallet.size()); printf("mapWallet.size() = %"PRIszu"\n", pwalletMain->mapWallet.size());
printf("mapAddressBook.size() = %d\n", pwalletMain->mapAddressBook.size()); printf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain->mapAddressBook.size());
if (!NewThread(StartNode, NULL)) if (!NewThread(StartNode, NULL))
InitError(_("Error: could not start node")); InitError(_("Error: could not start node"));

2
src/irc.cpp

@ -260,7 +260,7 @@ void ThreadIRCSeed2(void* parg)
if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3) if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3)
strMyName = EncodeAddress(GetLocalAddress(&addrConnect)); strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
if (strMyName == "") if (strMyName == "")
strMyName = strprintf("x%u", GetRand(1000000000)); strMyName = strprintf("x%"PRI64u"", GetRand(1000000000));
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str()); Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());

34
src/main.cpp

@ -181,7 +181,7 @@ bool AddOrphanTx(const CDataStream& vMsg)
// at most 500 megabytes of orphans: // at most 500 megabytes of orphans:
if (pvMsg->size() > 5000) if (pvMsg->size() > 5000)
{ {
printf("ignoring large orphan tx (size: %u, hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str()); printf("ignoring large orphan tx (size: %"PRIszu", hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str());
delete pvMsg; delete pvMsg;
return false; return false;
} }
@ -190,7 +190,7 @@ bool AddOrphanTx(const CDataStream& vMsg)
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(make_pair(hash, pvMsg)); mapOrphanTransactionsByPrev[txin.prevout.hash].insert(make_pair(hash, pvMsg));
printf("stored orphan tx %s (mapsz %u)\n", hash.ToString().substr(0,10).c_str(), printf("stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString().substr(0,10).c_str(),
mapOrphanTransactions.size()); mapOrphanTransactions.size());
return true; return true;
} }
@ -667,7 +667,7 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs,
if (ptxOld) if (ptxOld)
EraseFromWallets(ptxOld->GetHash()); EraseFromWallets(ptxOld->GetHash());
printf("CTxMemPool::accept() : accepted %s (poolsz %u)\n", printf("CTxMemPool::accept() : accepted %s (poolsz %"PRIszu")\n",
hash.ToString().substr(0,10).c_str(), hash.ToString().substr(0,10).c_str(),
mapTx.size()); mapTx.size());
return true; return true;
@ -1187,7 +1187,7 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTes
// Revisit this if/when transaction replacement is implemented and allows // Revisit this if/when transaction replacement is implemented and allows
// adding inputs: // adding inputs:
fInvalid = true; fInvalid = true;
return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %"PRIszu" %"PRIszu" prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()));
} }
} }
@ -1256,7 +1256,7 @@ bool CTransaction::ConnectInputs(MapPrevTx inputs,
CTransaction& txPrev = inputs[prevout.hash].second; CTransaction& txPrev = inputs[prevout.hash].second;
if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size())
return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %"PRIszu" %"PRIszu" prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()));
// If prev is coinbase, check that it's matured // If prev is coinbase, check that it's matured
if (txPrev.IsCoinBase()) if (txPrev.IsCoinBase())
@ -1541,8 +1541,8 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
vConnect.push_back(pindex); vConnect.push_back(pindex);
reverse(vConnect.begin(), vConnect.end()); reverse(vConnect.begin(), vConnect.end());
printf("REORGANIZE: Disconnect %i blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str());
printf("REORGANIZE: Connect %i blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); printf("REORGANIZE: Connect %"PRIszu" blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str());
// Disconnect shorter branch // Disconnect shorter branch
vector<CTransaction> vResurrect; vector<CTransaction> vResurrect;
@ -1670,7 +1670,7 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
} }
if (!vpindexSecondary.empty()) if (!vpindexSecondary.empty())
printf("Postponing %i reconnects\n", vpindexSecondary.size()); printf("Postponing %"PRIszu" reconnects\n", vpindexSecondary.size());
// Switch to new best branch // Switch to new best branch
if (!Reorganize(txdb, pindexIntermediate)) if (!Reorganize(txdb, pindexIntermediate))
@ -2218,7 +2218,7 @@ void PrintBlockTree()
// print item // print item
CBlock block; CBlock block;
block.ReadFromDisk(pindex); block.ReadFromDisk(pindex);
printf("%d (%u,%u) %s %s tx %d", printf("%d (%u,%u) %s %s tx %"PRIszu"",
pindex->nHeight, pindex->nHeight,
pindex->nFile, pindex->nFile,
pindex->nBlockPos, pindex->nBlockPos,
@ -2416,7 +2416,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
static map<CService, CPubKey> mapReuseKey; static map<CService, CPubKey> mapReuseKey;
RandAddSeedPerfmon(); RandAddSeedPerfmon();
if (fDebug) if (fDebug)
printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size()); printf("received: %s (%"PRIszu" bytes)\n", strCommand.c_str(), vRecv.size());
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{ {
printf("dropmessagestest DROPPING RECV MESSAGE\n"); printf("dropmessagestest DROPPING RECV MESSAGE\n");
@ -2561,7 +2561,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vAddr.size() > 1000) if (vAddr.size() > 1000)
{ {
pfrom->Misbehaving(20); pfrom->Misbehaving(20);
return error("message addr size() = %d", vAddr.size()); return error("message addr size() = %"PRIszu"", vAddr.size());
} }
// Store the new addresses // Store the new addresses
@ -2624,7 +2624,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vInv.size() > MAX_INV_SZ) if (vInv.size() > MAX_INV_SZ)
{ {
pfrom->Misbehaving(20); pfrom->Misbehaving(20);
return error("message inv size() = %d", vInv.size()); return error("message inv size() = %"PRIszu"", vInv.size());
} }
// find last block in inv vector // find last block in inv vector
@ -2674,11 +2674,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (vInv.size() > MAX_INV_SZ) if (vInv.size() > MAX_INV_SZ)
{ {
pfrom->Misbehaving(20); pfrom->Misbehaving(20);
return error("message getdata size() = %d", vInv.size()); return error("message getdata size() = %"PRIszu"", vInv.size());
} }
if (fDebugNet || (vInv.size() != 1)) if (fDebugNet || (vInv.size() != 1))
printf("received getdata (%d invsz)\n", vInv.size()); printf("received getdata (%"PRIszu" invsz)\n", vInv.size());
BOOST_FOREACH(const CInv& inv, vInv) BOOST_FOREACH(const CInv& inv, vInv)
{ {
@ -3072,7 +3072,7 @@ bool ProcessMessages(CNode* pfrom)
break; break;
} }
if (pstart - vRecv.begin() > 0) if (pstart - vRecv.begin() > 0)
printf("\n\nPROCESSMESSAGE SKIPPED %d BYTES\n\n", pstart - vRecv.begin()); printf("\n\nPROCESSMESSAGE SKIPPED %"PRIpdd" BYTES\n\n", pstart - vRecv.begin());
vRecv.erase(vRecv.begin(), pstart); vRecv.erase(vRecv.begin(), pstart);
// Read header // Read header
@ -3681,7 +3681,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
nLastBlockTx = nBlockTx; nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize; nLastBlockSize = nBlockSize;
printf("CreateNewBlock(): total size %lu\n", nBlockSize); printf("CreateNewBlock(): total size %"PRI64u"\n", nBlockSize);
pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees); pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees);
@ -3847,7 +3847,7 @@ void static BitcoinMiner(CWallet *pwallet)
return; return;
IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce); IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce);
printf("Running BitcoinMiner with %d transactions in block (%u bytes)\n", pblock->vtx.size(), printf("Running BitcoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));

6
src/main.h

@ -586,7 +586,7 @@ public:
std::string ToString() const std::string ToString() const
{ {
std::string str; std::string str;
str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n", str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%"PRIszu", vout.size=%"PRIszu", nLockTime=%u)\n",
GetHash().ToString().substr(0,10).c_str(), GetHash().ToString().substr(0,10).c_str(),
nVersion, nVersion,
vin.size(), vin.size(),
@ -952,7 +952,7 @@ public:
void print() const void print() const
{ {
printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%d)\n", printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu")\n",
GetHash().ToString().substr(0,20).c_str(), GetHash().ToString().substr(0,20).c_str(),
nVersion, nVersion,
hashPrevBlock.ToString().substr(0,20).c_str(), hashPrevBlock.ToString().substr(0,20).c_str(),
@ -1128,7 +1128,7 @@ public:
std::string ToString() const std::string ToString() const
{ {
return strprintf("CBlockIndex(pprev=%08x, pnext=%08x, nFile=%u, nBlockPos=%-6u nHeight=%d, merkle=%s, hashBlock=%s)", return strprintf("CBlockIndex(pprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6u nHeight=%d, merkle=%s, hashBlock=%s)",
pprev, pnext, nFile, nBlockPos, nHeight, pprev, pnext, nFile, nBlockPos, nHeight,
hashMerkleRoot.ToString().substr(0,10).c_str(), hashMerkleRoot.ToString().substr(0,10).c_str(),
GetBlockHash().ToString().substr(0,20).c_str()); GetBlockHash().ToString().substr(0,20).c_str());

2
src/net.cpp

@ -885,7 +885,7 @@ void ThreadSocketHandler2(void* parg)
if (nPos > ReceiveBufferSize()) { if (nPos > ReceiveBufferSize()) {
if (!pnode->fDisconnect) if (!pnode->fDisconnect)
printf("socket recv flood control disconnect (%d bytes)\n", vRecv.size()); printf("socket recv flood control disconnect (%"PRIszu" bytes)\n", vRecv.size());
pnode->CloseSocketDisconnect(); pnode->CloseSocketDisconnect();
} }
else { else {

2
src/rpcwallet.cpp

@ -725,7 +725,7 @@ Value addmultisigaddress(const Array& params, bool fHelp)
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 %d keys, but need at least %d to redeem)", keys.size(), nRequired)); "(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired));
std::vector<CKey> pubkeys; std::vector<CKey> 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/util.cpp

@ -156,7 +156,7 @@ void RandAddSeedPerfmon()
{ {
RAND_add(pdata, nSize, nSize/100.0); RAND_add(pdata, nSize, nSize/100.0);
memset(pdata, 0, nSize); memset(pdata, 0, nSize);
printf("RandAddSeed() %d bytes\n", nSize); printf("RandAddSeed() %lu bytes\n", nSize);
} }
#endif #endif
} }

6
src/wallet.cpp

@ -804,7 +804,7 @@ void CWallet::ReacceptWalletTransactions()
// Update fSpent if a tx got spent somewhere else by a copy of wallet.dat // Update fSpent if a tx got spent somewhere else by a copy of wallet.dat
if (txindex.vSpent.size() != wtx.vout.size()) if (txindex.vSpent.size() != wtx.vout.size())
{ {
printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %d != wtx.vout.size() %d\n", txindex.vSpent.size(), wtx.vout.size()); printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %"PRIszu" != wtx.vout.size() %"PRIszu"\n", txindex.vSpent.size(), wtx.vout.size());
continue; continue;
} }
for (unsigned int i = 0; i < txindex.vSpent.size(); i++) for (unsigned int i = 0; i < txindex.vSpent.size(); i++)
@ -1424,7 +1424,7 @@ void CWallet::PrintWallet(const CBlock& block)
if (mapWallet.count(block.vtx[0].GetHash())) if (mapWallet.count(block.vtx[0].GetHash()))
{ {
CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()]; CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()];
printf(" mine: %d %d %d", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); printf(" mine: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
} }
} }
printf("\n"); printf("\n");
@ -1511,7 +1511,7 @@ bool CWallet::TopUpKeyPool()
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);
printf("keypool added key %"PRI64d", size=%d\n", nEnd, setKeyPool.size()); printf("keypool added key %"PRI64d", size=%"PRIszu"\n", nEnd, setKeyPool.size());
} }
} }
return true; return true;

Loading…
Cancel
Save