Skip to content

Commit

Permalink
Fixed compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wqking committed Oct 20, 2021
1 parent ca740e8 commit 9c0cd6a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeMod
strSelectionMap.replace(pindex->nHeight - nHeightFirstCandidate, 1, "=");
pindex = pindex->pprev;
}
for (const PAIRTYPE(uint256, const CBlockIndex*) & item : mapSelectedBlocks) {
for (const PAIRTYPE(const uint256, const CBlockIndex*) & item : mapSelectedBlocks) {
// 'S' indicates selected proof-of-stake blocks
// 'W' indicates selected proof-of-work blocks
strSelectionMap.replace(item.second->nHeight - nHeightFirstCandidate, 1, item.second->IsProofOfStake() ? "S" : "W");
Expand Down
16 changes: 7 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ std::list<libzerocoin::CoinDenomination> ZerocoinSpendListFromBlock(const CBlock
if (!tx.IsZerocoinSpend())
continue;

for (const CTxIn txin : tx.vin) {
for (const CTxIn & txin : tx.vin) {
if (!txin.scriptSig.IsZerocoinSpend())
continue;

Expand Down Expand Up @@ -1424,7 +1424,7 @@ bool CheckTransaction(const CTransaction& tx, bool fZerocoinActive, bool fReject

if (tx.IsZerocoinSpend()) {
//require that a zerocoinspend only has inputs that are zerocoins
for (const CTxIn in : tx.vin) {
for (const CTxIn & in : tx.vin) {
if (!in.scriptSig.IsZerocoinSpend())
return state.DoS(100,
error("CheckTransaction() : zerocoinspend contains inputs that are not zerocoins"));
Expand Down Expand Up @@ -1627,7 +1627,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa
// do all inputs exist?
// Note that this does not check for the presence of actual outputs (see the next check for that),
// only helps filling in pfMissingInputs (to determine missing vs spent).
for (const CTxIn txin : tx.vin) {
for (const CTxIn & txin : tx.vin) {
if (!view.HaveCoins(txin.prevout.hash)) {
if (pfMissingInputs)
*pfMissingInputs = true;
Expand Down Expand Up @@ -1904,7 +1904,7 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact
// do all inputs exist?
// Note that this does not check for the presence of actual outputs (see the next check for that),
// only helps filling in pfMissingInputs (to determine missing vs spent).
for (const CTxIn txin : tx.vin) {
for (const CTxIn & txin : tx.vin) {
if (!view.HaveCoins(txin.prevout.hash)) {
if (pfMissingInputs)
*pfMissingInputs = true;
Expand Down Expand Up @@ -2536,7 +2536,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
if (tx.ContainsZerocoins()) {
if (tx.IsZerocoinSpend()) {
//erase all zerocoinspends in this transaction
for (const CTxIn txin : tx.vin) {
for (const CTxIn & txin : tx.vin) {
if (txin.scriptSig.IsZerocoinSpend()) {
CoinSpend spend = TxInToZerocoinSpend(txin);
if (!zerocoinDB->EraseCoinSpend(spend.getCoinSerialNumber()))
Expand Down Expand Up @@ -3267,7 +3267,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
for (const CTransaction& tx: block.vtx) {
if (tx.IsCoinBase() || tx.IsZerocoinSpend())
continue;
for (const CTxIn in: tx.vin) {
for (const CTxIn & in: tx.vin) {
LogPrint("map", "mapStakeSpent: Insert %s | %u\n", in.prevout.ToString(), pindex->nHeight);
mapStakeSpent.insert(std::make_pair(in.prevout, pindex->nHeight));
}
Expand Down Expand Up @@ -4424,7 +4424,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn

// double check that there are no double spent zPHR spends in this block
if (tx.IsZerocoinSpend()) {
for (const CTxIn txIn : tx.vin) {
for (const CTxIn & txIn : tx.vin) {
if (txIn.scriptSig.IsZerocoinSpend()) {
libzerocoin::CoinSpend spend = TxInToZerocoinSpend(txIn);
if (count(vBlockSerials.begin(), vBlockSerials.end(), spend.getCoinSerialNumber()))
Expand Down Expand Up @@ -6176,7 +6176,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
GetMainSignals().Inventory(inv.hash);

if (pfrom->nSendSize > (SendBufferSize() * 2)) {
LOCK(cs_main);
return error("send buffer size() = %u", pfrom->nSendSize);
}
}
Expand Down Expand Up @@ -6477,7 +6476,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
for (const CBlockHeader& header : headers) {
CValidationState state;
if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) {
LOCK(cs_main);
Misbehaving(pfrom->GetId(), 20);
return error("non-continuous headers sequence");
}
Expand Down
2 changes: 1 addition & 1 deletion src/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s
findScript << OP_RETURN << ToByteVector(nExpectedHash);

bool foundOpReturn = false;
for (const CTxOut o : txCollateral.vout) {
for (const CTxOut & o : txCollateral.vout) {
if (!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()) {
strError = strprintf("Invalid Script %s", txCollateral.ToString());
LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError);
Expand Down
26 changes: 13 additions & 13 deletions src/obfuscation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void CObfuscationPool::ProcessMessageObfuscation(CNode* pfrom, std::string& strC
CValidationState state;
CMutableTransaction tx;

for (const CTxOut o : out) {
for (const CTxOut & o : out) {
nValueOut += o.nValue;
tx.vout.push_back(o);

Expand All @@ -222,7 +222,7 @@ void CObfuscationPool::ProcessMessageObfuscation(CNode* pfrom, std::string& strC
}
}

for (const CTxIn i : in) {
for (const CTxIn & i : in) {
tx.vin.push_back(i);

LogPrint("obfuscation", "dsi -- tx in %s\n", i.ToString());
Expand Down Expand Up @@ -318,7 +318,7 @@ void CObfuscationPool::ProcessMessageObfuscation(CNode* pfrom, std::string& strC
bool success = false;
int count = 0;

for (const CTxIn item : sigs) {
for (const CTxIn & item : sigs) {
if (AddScriptSig(item)) success = true;
LogPrint("obfuscation", " -- sigs count %d %d\n", (int)sigs.size(), count);
count++;
Expand Down Expand Up @@ -690,8 +690,8 @@ void CObfuscationPool::ChargeFees()

if (state == POOL_STATUS_SIGNING) {
// who didn't sign?
for (const CObfuScationEntry v : entries) {
for (const CTxDSIn s : v.sev) {
for (const CObfuScationEntry & v : entries) {
for (const CTxDSIn & s : v.sev) {
if (!s.fHasSig) {
LogPrintf("CObfuscationPool::ChargeFees -- found uncooperative node (didn't sign). Found offence\n");
offences++;
Expand Down Expand Up @@ -743,8 +743,8 @@ void CObfuscationPool::ChargeFees()

if (state == POOL_STATUS_SIGNING) {
// who didn't sign?
for (const CObfuScationEntry v : entries) {
for (const CTxDSIn s : v.sev) {
for (const CObfuScationEntry & v : entries) {
for (const CTxDSIn & s : v.sev) {
if (!s.fHasSig && r > target) {
LogPrintf("CObfuscationPool::ChargeFees -- found uncooperative node (didn't sign). charging fees.\n");

Expand Down Expand Up @@ -960,7 +960,7 @@ bool CObfuscationPool::IsCollateralValid(const CTransaction& txCollateral)
int64_t nValueOut = 0;
bool missingTx = false;

for (const CTxOut o : txCollateral.vout) {
for (const CTxOut & o : txCollateral.vout) {
nValueOut += o.nValue;

if (!o.scriptPubKey.IsNormalPaymentScript()) {
Expand All @@ -969,7 +969,7 @@ bool CObfuscationPool::IsCollateralValid(const CTransaction& txCollateral)
}
}

for (const CTxIn i : txCollateral.vin) {
for (const CTxIn & i : txCollateral.vin) {
CTransaction tx2;
uint256 hash;
if (GetTransaction(i.prevout.hash, tx2, hash, true)) {
Expand Down Expand Up @@ -1268,8 +1268,8 @@ bool CObfuscationPool::SignFinalTransaction(CTransaction& finalTransactionNew, C
vector<CTxIn> sigs;

//make sure my inputs/outputs are present, otherwise refuse to sign
for (const CObfuScationEntry e : entries) {
for (const CTxDSIn s : e.sev) {
for (const CObfuScationEntry & e : entries) {
for (const CTxDSIn & s : e.sev) {
/* Sign my transaction and all outputs */
int mine = -1;
CScript prevPubKey = CScript();
Expand Down Expand Up @@ -1298,7 +1298,7 @@ bool CObfuscationPool::SignFinalTransaction(CTransaction& finalTransactionNew, C
}
}

for (const CTxOut o : e.vout)
for (const CTxOut & o : e.vout)
nValue2 += o.nValue;

int targetOuputs = e.vout.size();
Expand Down Expand Up @@ -1845,7 +1845,7 @@ bool CObfuscationPool::IsCompatibleWithEntries(std::vector<CTxOut>& vout)
{
if (GetDenominations(vout) == 0) return false;

for (const CObfuScationEntry v : entries) {
for (const CObfuScationEntry & v : entries) {
LogPrintf(" IsCompatibleWithEntries %d %d\n", GetDenominations(vout), GetDenominations(v.vout));
/*
for (CTxOut o1 : vout)
Expand Down
4 changes: 2 additions & 2 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ bool ClientModel::getTorInfo(std::string& ip_port) const
if (GetProxy((Network) 3, onion) && IsReachable((Network) 3)) {
{
LOCK(cs_mapLocalHost);
for (const std::pair<CNetAddr, LocalServiceInfo> &item : mapLocalHost) {
for (const std::pair<const CNetAddr, LocalServiceInfo> &item : mapLocalHost) {
if (item.first.IsTor()) {
CService addrOnion = CService(item.first.ToString(), item.second.nPort);
ip_port = addrOnion.ToStringIPPort();
Expand All @@ -317,4 +317,4 @@ bool ClientModel::getTorInfo(std::string& ip_port) const
}
}
return false;
}
}
2 changes: 1 addition & 1 deletion src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp)
UniValue localAddresses(UniValue::VARR);
{
LOCK(cs_mapLocalHost);
for (const PAIRTYPE(CNetAddr, LocalServiceInfo) & item : mapLocalHost) {
for (const PAIRTYPE(const CNetAddr, LocalServiceInfo) & item : mapLocalHost) {
UniValue rec(UniValue::VOBJ);
rec.push_back(Pair("address", item.first.ToString()));
rec.push_back(Pair("port", item.second.nPort));
Expand Down
6 changes: 3 additions & 3 deletions src/swifttx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void ProcessMessageSwiftTX(CNode* pfrom, std::string& strCommand, CDataStream& v
return;
}

for (const CTxOut o : tx.vout) {
for (const CTxOut & o : tx.vout) {
// IX supports normal scripts and unspendable scripts (used in DS collateral and Budget collateral).
// TODO: Look into other script types that are normal and can be included
if (!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()) {
Expand Down Expand Up @@ -186,10 +186,10 @@ bool IsIXTXValid(const CTransaction& txCollateral)
CAmount nValueOut = 0;
bool missingTx = false;

for (const CTxOut o : txCollateral.vout)
for (const CTxOut & o : txCollateral.vout)
nValueOut += o.nValue;

for (const CTxIn i : txCollateral.vin) {
for (const CTxIn & i : txCollateral.vin) {
CTransaction tx2;
uint256 hash;
if (GetTransaction(i.prevout.hash, tx2, hash, true)) {
Expand Down
4 changes: 2 additions & 2 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ void CTxMemPool::check(const CCoinsViewCache* pcoins) const
else {
CValidationState state;
CTxUndo undo;
assert(CheckInputs(tx, state, mempoolDuplicate, false, 0, false, NULL));
assert(CheckInputs(tx, state, mempoolDuplicate, false, 0, false, false));
UpdateCoins(tx, state, mempoolDuplicate, undo, 1000000);
}
}
Expand All @@ -606,7 +606,7 @@ void CTxMemPool::check(const CCoinsViewCache* pcoins) const
stepsSinceLastRemove++;
assert(stepsSinceLastRemove < waitingOnDependants.size());
} else {
assert(CheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, NULL));
assert(CheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, false));
CTxUndo undo;
UpdateCoins(entry->GetTx(), state, mempoolDuplicate, undo, 1000000);
stepsSinceLastRemove = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/crypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ bool EncryptAES256(const SecureString& sKey, const SecureString& sPlaintext, con

// Perform the encryption
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
EVP_CIPHER_CTX* ctx;
EVP_CIPHER_CTX* ctx = nullptr;
#else
EVP_CIPHER_CTX ctx;
#endif
Expand Down

0 comments on commit 9c0cd6a

Please sign in to comment.