Skip to content

Commit baae314

Browse files
committed
Merge #9911: Wshadow: various gcc fixes
d7f80b6 Rename first iterator to prevent shadowing. (Pavel Janík) b42ff60 Fix shadowing of local variables. (Pavel Janík) c4b60b3 Make some global variables less-global (static) (Pavel Janík) bb2aaee Prevent -Wshadow warnings with gcc versions 4.8.5, 5.3.1 and 6.2.1. (Pavel Janík) Tree-SHA512: 3aea4e28146c8f2a31351c6e2b0cce88b6f1e567a0ea0e6131624453e7193d0904e30d81b1439d8c69e281cf0e369b895851fb882ae48d5967b5c2e2c227404e
2 parents a328904 + d7f80b6 commit baae314

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

src/streams.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ class CDataStream
404404
return (*this);
405405
}
406406

407-
void GetAndClear(CSerializeData &data) {
408-
data.insert(data.end(), begin(), end());
407+
void GetAndClear(CSerializeData &d) {
408+
d.insert(d.end(), begin(), end());
409409
clear();
410410
}
411411

src/test/checkqueue_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct FakeCheckCheckCompletion {
4646

4747
struct FailingCheck {
4848
bool fails;
49-
FailingCheck(bool fails) : fails(fails){};
49+
FailingCheck(bool _fails) : fails(_fails){};
5050
FailingCheck() : fails(true){};
5151
bool operator()()
5252
{
@@ -411,15 +411,15 @@ BOOST_AUTO_TEST_CASE(test_CheckQueueControl_Locks)
411411
std::unique_lock<std::mutex> l(m);
412412
tg.create_thread([&]{
413413
CCheckQueueControl<FakeCheck> control(queue.get());
414-
std::unique_lock<std::mutex> l(m);
414+
std::unique_lock<std::mutex> ll(m);
415415
has_lock = true;
416416
cv.notify_one();
417-
cv.wait(l, [&]{return has_tried;});
417+
cv.wait(ll, [&]{return has_tried;});
418418
done = true;
419419
cv.notify_one();
420420
// Wait until the done is acknowledged
421421
//
422-
cv.wait(l, [&]{return done_ack;});
422+
cv.wait(ll, [&]{return done_ack;});
423423
});
424424
// Wait for thread to get the lock
425425
cv.wait(l, [&](){return has_lock;});

src/test/script_tests.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// Uncomment if you want to output updated JSON tests.
3333
// #define UPDATE_JSON_TESTS
3434

35-
static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC;
35+
static const unsigned int gFlags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC;
3636

3737
unsigned int ParseScriptFlags(std::string strFlags);
3838
std::string FormatScriptFlags(unsigned int flags);
@@ -1065,18 +1065,18 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG12)
10651065
CMutableTransaction txTo12 = BuildSpendingTransaction(CScript(), CScriptWitness(), txFrom12);
10661066

10671067
CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12);
1068-
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, NULL, flags, MutableTransactionSignatureChecker(&txTo12, 0, txFrom12.vout[0].nValue), &err));
1068+
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, NULL, gFlags, MutableTransactionSignatureChecker(&txTo12, 0, txFrom12.vout[0].nValue), &err));
10691069
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
10701070
txTo12.vout[0].nValue = 2;
1071-
BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, NULL, flags, MutableTransactionSignatureChecker(&txTo12, 0, txFrom12.vout[0].nValue), &err));
1071+
BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, NULL, gFlags, MutableTransactionSignatureChecker(&txTo12, 0, txFrom12.vout[0].nValue), &err));
10721072
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
10731073

10741074
CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12);
1075-
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, NULL, flags, MutableTransactionSignatureChecker(&txTo12, 0, txFrom12.vout[0].nValue), &err));
1075+
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, NULL, gFlags, MutableTransactionSignatureChecker(&txTo12, 0, txFrom12.vout[0].nValue), &err));
10761076
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
10771077

10781078
CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12);
1079-
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, NULL, flags, MutableTransactionSignatureChecker(&txTo12, 0, txFrom12.vout[0].nValue), &err));
1079+
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, NULL, gFlags, MutableTransactionSignatureChecker(&txTo12, 0, txFrom12.vout[0].nValue), &err));
10801080
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
10811081
}
10821082

@@ -1098,54 +1098,54 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23)
10981098
std::vector<CKey> keys;
10991099
keys.push_back(key1); keys.push_back(key2);
11001100
CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23);
1101-
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1101+
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11021102
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
11031103

11041104
keys.clear();
11051105
keys.push_back(key1); keys.push_back(key3);
11061106
CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23);
1107-
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1107+
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11081108
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
11091109

11101110
keys.clear();
11111111
keys.push_back(key2); keys.push_back(key3);
11121112
CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23);
1113-
BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1113+
BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11141114
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
11151115

11161116
keys.clear();
11171117
keys.push_back(key2); keys.push_back(key2); // Can't re-use sig
11181118
CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23);
1119-
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1119+
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11201120
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
11211121

11221122
keys.clear();
11231123
keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order
11241124
CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23);
1125-
BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1125+
BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11261126
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
11271127

11281128
keys.clear();
11291129
keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order
11301130
CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23);
1131-
BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1131+
BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11321132
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
11331133

11341134
keys.clear();
11351135
keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys
11361136
CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23);
1137-
BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1137+
BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11381138
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
11391139

11401140
keys.clear();
11411141
keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys
11421142
CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23);
1143-
BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1143+
BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11441144
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
11451145

11461146
keys.clear(); // Must have signatures
11471147
CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23);
1148-
BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, NULL, flags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
1148+
BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, NULL, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue), &err));
11491149
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString(err));
11501150
}
11511151

src/torcontrol.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -662,26 +662,26 @@ void TorController::reconnect_cb(evutil_socket_t fd, short what, void *arg)
662662
}
663663

664664
/****** Thread ********/
665-
struct event_base *base;
666-
boost::thread torControlThread;
665+
static struct event_base *gBase;
666+
static boost::thread torControlThread;
667667

668668
static void TorControlThread()
669669
{
670-
TorController ctrl(base, GetArg("-torcontrol", DEFAULT_TOR_CONTROL));
670+
TorController ctrl(gBase, GetArg("-torcontrol", DEFAULT_TOR_CONTROL));
671671

672-
event_base_dispatch(base);
672+
event_base_dispatch(gBase);
673673
}
674674

675675
void StartTorControl(boost::thread_group& threadGroup, CScheduler& scheduler)
676676
{
677-
assert(!base);
677+
assert(!gBase);
678678
#ifdef WIN32
679679
evthread_use_windows_threads();
680680
#else
681681
evthread_use_pthreads();
682682
#endif
683-
base = event_base_new();
684-
if (!base) {
683+
gBase = event_base_new();
684+
if (!gBase) {
685685
LogPrintf("tor: Unable to create event_base\n");
686686
return;
687687
}
@@ -691,18 +691,18 @@ void StartTorControl(boost::thread_group& threadGroup, CScheduler& scheduler)
691691

692692
void InterruptTorControl()
693693
{
694-
if (base) {
694+
if (gBase) {
695695
LogPrintf("tor: Thread interrupt\n");
696-
event_base_loopbreak(base);
696+
event_base_loopbreak(gBase);
697697
}
698698
}
699699

700700
void StopTorControl()
701701
{
702-
if (base) {
702+
if (gBase) {
703703
torControlThread.join();
704-
event_base_free(base);
705-
base = 0;
704+
event_base_free(gBase);
705+
gBase = 0;
706706
}
707707
}
708708

src/wallet/db.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,11 +604,11 @@ bool CDB::PeriodicFlush(std::string strFile)
604604
{
605605
// Don't do this if any databases are in use
606606
int nRefCount = 0;
607-
std::map<std::string, int>::iterator mi = bitdb.mapFileUseCount.begin();
608-
while (mi != bitdb.mapFileUseCount.end())
607+
std::map<std::string, int>::iterator mit = bitdb.mapFileUseCount.begin();
608+
while (mit != bitdb.mapFileUseCount.end())
609609
{
610-
nRefCount += (*mi).second;
611-
mi++;
610+
nRefCount += (*mit).second;
611+
mit++;
612612
}
613613

614614
if (nRefCount == 0)

0 commit comments

Comments
 (0)