diff --git a/src/kernel.cpp b/src/kernel.cpp index 243ad1a00cecb..23441cc20cffb 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -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"); diff --git a/src/main.cpp b/src/main.cpp index ff79eb0880d70..4133a2f53c18e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1227,7 +1227,7 @@ std::list ZerocoinSpendListFromBlock(const CBlock if (!tx.IsZerocoinSpend()) continue; - for (const CTxIn txin : tx.vin) { + for (const CTxIn & txin : tx.vin) { if (!txin.scriptSig.IsZerocoinSpend()) continue; @@ -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")); @@ -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; @@ -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; @@ -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())) @@ -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)); } @@ -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())) @@ -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); } } @@ -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"); } diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 787d3abd0e0bc..a0ddb5e5533f4 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -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); diff --git a/src/obfuscation.cpp b/src/obfuscation.cpp index f060b308247f2..12d57f402232b 100644 --- a/src/obfuscation.cpp +++ b/src/obfuscation.cpp @@ -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); @@ -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()); @@ -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++; @@ -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++; @@ -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"); @@ -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()) { @@ -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)) { @@ -1268,8 +1268,8 @@ bool CObfuscationPool::SignFinalTransaction(CTransaction& finalTransactionNew, C vector 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(); @@ -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(); @@ -1845,7 +1845,7 @@ bool CObfuscationPool::IsCompatibleWithEntries(std::vector& 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) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 17aa3b4284224..f54c7935e09c4 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -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 &item : mapLocalHost) { + for (const std::pair &item : mapLocalHost) { if (item.first.IsTor()) { CService addrOnion = CService(item.first.ToString(), item.second.nPort); ip_port = addrOnion.ToStringIPPort(); @@ -317,4 +317,4 @@ bool ClientModel::getTorInfo(std::string& ip_port) const } } return false; -} \ No newline at end of file +} diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index a5d45748bf834..593242617501f 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -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)); diff --git a/src/swifttx.cpp b/src/swifttx.cpp index 7e36b9ac214ef..22794d1ce9cc8 100644 --- a/src/swifttx.cpp +++ b/src/swifttx.cpp @@ -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()) { @@ -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)) { diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 100ebf1f0a2ed..5f584ce14b9d8 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -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); } } @@ -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; diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp index 00862ef0a634f..0cfe7ae8aa13a 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -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