Skip to content

Commit

Permalink
Do not shadow variables
Browse files Browse the repository at this point in the history
  • Loading branch information
paveljanik committed Sep 27, 2016
1 parent 2f71490 commit 4731cab
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 89 deletions.
8 changes: 4 additions & 4 deletions src/bloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey)

void CRollingBloomFilter::insert(const uint256& hash)
{
vector<unsigned char> data(hash.begin(), hash.end());
insert(data);
vector<unsigned char> vData(hash.begin(), hash.end());
insert(vData);
}

bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
Expand All @@ -300,8 +300,8 @@ bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const

bool CRollingBloomFilter::contains(const uint256& hash) const
{
vector<unsigned char> data(hash.begin(), hash.end());
return contains(data);
vector<unsigned char> vData(hash.begin(), hash.end());
return contains(vData);
}

void CRollingBloomFilter::reset()
Expand Down
6 changes: 3 additions & 3 deletions src/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const
return ret;
}

bool CExtKey::Derive(CExtKey &out, unsigned int nChild) const {
bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const {
out.nDepth = nDepth + 1;
CKeyID id = key.GetPubKey().GetID();
memcpy(&out.vchFingerprint[0], &id, 4);
out.nChild = nChild;
return key.Derive(out.key, out.chaincode, nChild, chaincode);
out.nChild = _nChild;
return key.Derive(out.key, out.chaincode, _nChild, chaincode);
}

void CExtKey::SetMaster(const unsigned char *seed, unsigned int nSeedLen) {
Expand Down
28 changes: 14 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,9 +1185,9 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
bool fReplacementOptOut = true;
if (fEnableReplacement)
{
BOOST_FOREACH(const CTxIn &txin, ptxConflicting->vin)
BOOST_FOREACH(const CTxIn &_txin, ptxConflicting->vin)
{
if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1)
if (_txin.nSequence < std::numeric_limits<unsigned int>::max()-1)
{
fReplacementOptOut = false;
break;
Expand Down Expand Up @@ -2499,14 +2499,14 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
{
if (pindex->GetUndoPos().IsNull()) {
CDiskBlockPos pos;
if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
CDiskBlockPos _pos;
if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
return error("ConnectBlock(): FindUndoPos failed");
if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
return AbortNode(state, "Failed to write undo data");

// update nUndoPos in block index
pindex->nUndoPos = pos.nPos;
pindex->nUndoPos = _pos.nPos;
pindex->nStatus |= BLOCK_HAVE_UNDO;
}

Expand Down Expand Up @@ -3819,10 +3819,10 @@ void PruneOneBlockFile(const int fileNumber)
// mapBlocksUnlinked or setBlockIndexCandidates.
std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev);
while (range.first != range.second) {
std::multimap<CBlockIndex *, CBlockIndex *>::iterator it = range.first;
std::multimap<CBlockIndex *, CBlockIndex *>::iterator _it = range.first;
range.first++;
if (it->second == pindex) {
mapBlocksUnlinked.erase(it);
if (_it->second == pindex) {
mapBlocksUnlinked.erase(_it);
}
}
}
Expand Down Expand Up @@ -5550,9 +5550,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
if (!fRejectedParents) {
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
CInv inv(MSG_TX, txin.prevout.hash);
pfrom->AddInventoryKnown(inv);
if (!AlreadyHave(inv)) pfrom->AskFor(inv);
CInv _inv(MSG_TX, txin.prevout.hash);
pfrom->AddInventoryKnown(_inv);
if (!AlreadyHave(_inv)) pfrom->AskFor(_inv);
}
AddOrphanTx(tx, pfrom->GetId());

Expand Down Expand Up @@ -6317,9 +6317,9 @@ class CompareInvMempoolOrder
{
CTxMemPool *mp;
public:
CompareInvMempoolOrder(CTxMemPool *mempool)
CompareInvMempoolOrder(CTxMemPool *_mempool)
{
mp = mempool;
mp = _mempool;
}

bool operator()(std::set<uint256>::iterator a, std::set<uint256>::iterator b)
Expand Down
6 changes: 3 additions & 3 deletions src/pubkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ void CExtPubKey::Decode(const unsigned char code[BIP32_EXTKEY_SIZE]) {
pubkey.Set(code+41, code+BIP32_EXTKEY_SIZE);
}

bool CExtPubKey::Derive(CExtPubKey &out, unsigned int nChild) const {
bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const {
out.nDepth = nDepth + 1;
CKeyID id = pubkey.GetID();
memcpy(&out.vchFingerprint[0], &id, 4);
out.nChild = nChild;
return pubkey.Derive(out.pubkey, out.chaincode, nChild, chaincode);
out.nChild = _nChild;
return pubkey.Derive(out.pubkey, out.chaincode, _nChild, chaincode);
}

/* static */ bool CPubKey::CheckLowS(const std::vector<unsigned char>& vchSig) {
Expand Down
4 changes: 2 additions & 2 deletions src/pubkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class CPubKey
}

//! Construct a public key from a byte vector.
CPubKey(const std::vector<unsigned char>& vch)
CPubKey(const std::vector<unsigned char>& _vch)
{
Set(vch.begin(), vch.end());
Set(_vch.begin(), _vch.end());
}

//! Simple read-only vector-like interface to the pubkey data.
Expand Down
6 changes: 3 additions & 3 deletions src/reverselock.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class reverse_lock
{
public:

explicit reverse_lock(Lock& lock) : lock(lock) {
lock.unlock();
lock.swap(templock);
explicit reverse_lock(Lock& _lock) : lock(_lock) {
_lock.unlock();
_lock.swap(templock);
}

~reverse_lock() {
Expand Down
8 changes: 4 additions & 4 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,10 @@ UniValue getmempoolancestors(const UniValue& params, bool fHelp)
UniValue o(UniValue::VOBJ);
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
const CTxMemPoolEntry &e = *ancestorIt;
const uint256& hash = e.GetTx().GetHash();
const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
entryToJSON(info, e);
o.push_back(Pair(hash.ToString(), info));
o.push_back(Pair(_hash.ToString(), info));
}
return o;
}
Expand Down Expand Up @@ -561,10 +561,10 @@ UniValue getmempooldescendants(const UniValue& params, bool fHelp)
UniValue o(UniValue::VOBJ);
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
const CTxMemPoolEntry &e = *descendantIt;
const uint256& hash = e.GetTx().GetHash();
const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
entryToJSON(info, e);
o.push_back(Pair(hash.ToString(), info));
o.push_back(Pair(_hash.ToString(), info));
}
return o;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)

UniValue aRules(UniValue::VARR);
UniValue vbavailable(UniValue::VOBJ);
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
Consensus::DeploymentPos pos = Consensus::DeploymentPos(i);
for (int j = 0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
Consensus::DeploymentPos pos = Consensus::DeploymentPos(j);
ThresholdState state = VersionBitsState(pindexPrev, consensusParams, pos, versionbitscache);
switch (state) {
case THRESHOLD_DEFINED:
Expand Down
6 changes: 3 additions & 3 deletions src/support/pagelocker.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ template <class Locker>
class LockedPageManagerBase
{
public:
LockedPageManagerBase(size_t page_size) : page_size(page_size)
LockedPageManagerBase(size_t _page_size) : page_size(_page_size)
{
// Determine bitmask for extracting page from address
assert(!(page_size & (page_size - 1))); // size must be power of two
page_mask = ~(page_size - 1);
assert(!(_page_size & (_page_size - 1))); // size must be power of two
page_mask = ~(_page_size - 1);
}

~LockedPageManagerBase()
Expand Down
20 changes: 10 additions & 10 deletions src/test/crypto_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ void TestAES128CBC(const std::string &hexkey, const std::string &hexiv, bool pad
{
std::vector<unsigned char> sub(i, in.end());
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
int size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
if (size != 0)
int _size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
if (_size != 0)
{
subout.resize(size);
subout.resize(_size);
std::vector<unsigned char> subdecrypted(subout.size());
size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
subdecrypted.resize(size);
_size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
subdecrypted.resize(_size);
BOOST_CHECK(decrypted.size() == in.size());
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(" != ") + HexStr(sub));
}
Expand Down Expand Up @@ -174,13 +174,13 @@ void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, bool pad
{
std::vector<unsigned char> sub(i, in.end());
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
int size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
if (size != 0)
int _size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
if (_size != 0)
{
subout.resize(size);
subout.resize(_size);
std::vector<unsigned char> subdecrypted(subout.size());
size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
subdecrypted.resize(size);
_size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
subdecrypted.resize(_size);
BOOST_CHECK(decrypted.size() == in.size());
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(" != ") + HexStr(sub));
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/net_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class CAddrManCorrupted : public CAddrManSerializationMock
}
};

CDataStream AddrmanToStream(CAddrManSerializationMock& addrman)
CDataStream AddrmanToStream(CAddrManSerializationMock& _addrman)
{
CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION);
ssPeersIn << FLATDATA(Params().MessageStart());
ssPeersIn << addrman;
ssPeersIn << _addrman;
std::string str = ssPeersIn.str();
vector<unsigned char> vchData(str.begin(), str.end());
return CDataStream(vchData, SER_DISK, CLIENT_VERSION);
Expand Down
8 changes: 4 additions & 4 deletions src/test/script_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ class TestBuilder
return *this;
}

TestBuilder& Add(const CScript& script)
TestBuilder& Add(const CScript& _script)
{
DoPush();
spendTx.vin[0].scriptSig += script;
spendTx.vin[0].scriptSig += _script;
return *this;
}

Expand All @@ -343,8 +343,8 @@ class TestBuilder
return *this;
}

TestBuilder& Push(const CScript& script) {
DoPush(std::vector<unsigned char>(script.begin(), script.end()));
TestBuilder& Push(const CScript& _script) {
DoPush(std::vector<unsigned char>(_script.begin(), _script.end()));
return *this;
}

Expand Down
Loading

0 comments on commit 4731cab

Please sign in to comment.