Skip to content

Commit 75d012e

Browse files
committed
Merge #8808: Do not shadow variables (gcc set)
ad1ae7a Check and enable -Wshadow by default. (Pavel Janík) 9de90bb Do not shadow variables (gcc set) (Pavel Janík) Tree-SHA512: 9517feb423dc8ddd63896016b25324673bfbe0bffa97f22996f59d7a3fcbdc2ebf2e43ac02bc067546f54e293e9b2f2514be145f867321e9031f895c063d9fb8
2 parents ba80a68 + ad1ae7a commit 75d012e

File tree

15 files changed

+46
-45
lines changed

15 files changed

+46
-45
lines changed

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
227227
AX_CHECK_COMPILE_FLAG([-Wformat],[CXXFLAGS="$CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
228228
AX_CHECK_COMPILE_FLAG([-Wvla],[CXXFLAGS="$CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]])
229229
AX_CHECK_COMPILE_FLAG([-Wformat-security],[CXXFLAGS="$CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
230+
AX_CHECK_COMPILE_FLAG([-Wshadow],[CXXFLAGS="$CXXFLAGS -Wshadow"],,[[$CXXFLAG_WERROR]])
230231

231232
## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
232233
## unknown options if any other warning is produced. Test the -Wfoo case, and

src/arith_uint256.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ unsigned int base_uint<BITS>::bits() const
173173
{
174174
for (int pos = WIDTH - 1; pos >= 0; pos--) {
175175
if (pn[pos]) {
176-
for (int bits = 31; bits > 0; bits--) {
177-
if (pn[pos] & 1 << bits)
178-
return 32 * pos + bits + 1;
176+
for (int nbits = 31; nbits > 0; nbits--) {
177+
if (pn[pos] & 1 << nbits)
178+
return 32 * pos + nbits + 1;
179179
}
180180
return 32 * pos + 1;
181181
}

src/bench/lockedpool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define BITER 5000
1414
#define MSIZE 2048
1515

16-
static void LockedPool(benchmark::State& state)
16+
static void BenchLockedPool(benchmark::State& state)
1717
{
1818
void *synth_base = reinterpret_cast<void*>(0x08000000);
1919
const size_t synth_size = 1024*1024;
@@ -43,5 +43,5 @@ static void LockedPool(benchmark::State& state)
4343
addr.clear();
4444
}
4545

46-
BENCHMARK(LockedPool);
46+
BENCHMARK(BenchLockedPool);
4747

src/chain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ class CDiskBlockIndex : public CBlockIndex
367367

368368
template <typename Stream, typename Operation>
369369
inline void SerializationOp(Stream& s, Operation ser_action) {
370-
int nVersion = s.GetVersion();
370+
int _nVersion = s.GetVersion();
371371
if (!(s.GetType() & SER_GETHASH))
372-
READWRITE(VARINT(nVersion));
372+
READWRITE(VARINT(_nVersion));
373373

374374
READWRITE(VARINT(nHeight));
375375
READWRITE(VARINT(nStatus));

src/script/interpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class MutableTransactionSignatureChecker : public TransactionSignatureChecker
171171
const CTransaction txTo;
172172

173173
public:
174-
MutableTransactionSignatureChecker(const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amount) : TransactionSignatureChecker(&txTo, nInIn, amount), txTo(*txToIn) {}
174+
MutableTransactionSignatureChecker(const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn) : TransactionSignatureChecker(&txTo, nInIn, amountIn), txTo(*txToIn) {}
175175
};
176176

177177
bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptError* error = NULL);

src/script/script.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,18 @@ unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const
186186
// get the last item that the scriptSig
187187
// pushes onto the stack:
188188
const_iterator pc = scriptSig.begin();
189-
vector<unsigned char> data;
189+
vector<unsigned char> vData;
190190
while (pc < scriptSig.end())
191191
{
192192
opcodetype opcode;
193-
if (!scriptSig.GetOp(pc, opcode, data))
193+
if (!scriptSig.GetOp(pc, opcode, vData))
194194
return 0;
195195
if (opcode > OP_16)
196196
return 0;
197197
}
198198

199199
/// ... and return its opcount:
200-
CScript subscript(data.begin(), data.end());
200+
CScript subscript(vData.begin(), vData.end());
201201
return subscript.GetSigOpCount(true);
202202
}
203203

src/script/script.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,16 @@ class CScript : public CScriptBase
448448
else if (b.size() <= 0xffff)
449449
{
450450
insert(end(), OP_PUSHDATA2);
451-
uint8_t data[2];
452-
WriteLE16(data, b.size());
453-
insert(end(), data, data + sizeof(data));
451+
uint8_t _data[2];
452+
WriteLE16(_data, b.size());
453+
insert(end(), _data, _data + sizeof(_data));
454454
}
455455
else
456456
{
457457
insert(end(), OP_PUSHDATA4);
458-
uint8_t data[4];
459-
WriteLE32(data, b.size());
460-
insert(end(), data, data + sizeof(data));
458+
uint8_t _data[4];
459+
WriteLE32(_data, b.size());
460+
insert(end(), _data, _data + sizeof(_data));
461461
}
462462
insert(end(), b.begin(), b.end());
463463
return *this;

src/script/sigcache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CachingTransactionSignatureChecker : public TransactionSignatureChecker
2525
bool store;
2626

2727
public:
28-
CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amount, bool storeIn, PrecomputedTransactionData& txdataIn) : TransactionSignatureChecker(txToIn, nInIn, amount, txdataIn), store(storeIn) {}
28+
CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, bool storeIn, PrecomputedTransactionData& txdataIn) : TransactionSignatureChecker(txToIn, nInIn, amountIn, txdataIn), store(storeIn) {}
2929

3030
bool VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const;
3131
};

src/script/sign.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class MutableTransactionSignatureCreator : public TransactionSignatureCreator {
4848
CTransaction tx;
4949

5050
public:
51-
MutableTransactionSignatureCreator(const CKeyStore* keystoreIn, const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amount, int nHashTypeIn) : TransactionSignatureCreator(keystoreIn, &tx, nInIn, amount, nHashTypeIn), tx(*txToIn) {}
51+
MutableTransactionSignatureCreator(const CKeyStore* keystoreIn, const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : TransactionSignatureCreator(keystoreIn, &tx, nInIn, amountIn, nHashTypeIn), tx(*txToIn) {}
5252
};
5353

5454
/** A signature creator that just produces 72-byte empty signatures. */

src/streams.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,11 @@ class CBufferedFile
584584
readNow = nAvail;
585585
if (readNow == 0)
586586
return false;
587-
size_t read = fread((void*)&vchBuf[pos], 1, readNow, src);
588-
if (read == 0) {
587+
size_t nBytes = fread((void*)&vchBuf[pos], 1, readNow, src);
588+
if (nBytes == 0) {
589589
throw std::ios_base::failure(feof(src) ? "CBufferedFile::Fill: end of file" : "CBufferedFile::Fill: fread failed");
590590
} else {
591-
nSrcPos += read;
591+
nSrcPos += nBytes;
592592
return true;
593593
}
594594
}

0 commit comments

Comments
 (0)