test: Move variable state down where it is used#10739
Merged
maflcko merged 1 commit intobitcoin:masterfrom Jul 16, 2017
Merged
Conversation
Contributor
|
utACK 46d53a65f8627f3d65baab00abf26bba3b6259b8 |
promag
reviewed
Jul 4, 2017
Contributor
promag
left a comment
There was a problem hiding this comment.
Why not remove the upper declaration as it isn't used in that scope and state is not shared across those blocks?
Contributor
Author
|
@promag no particular reason other than loosing 3- diff status... |
Contributor
|
utACK 46d53a6 |
Member
|
I'd prefer the +1-1 diff suggested by promag. This way, the state does not leak into the outer scope. diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp
index a74f402..3d8a4fd 100644
--- a/src/test/txvalidationcache_tests.cpp
+++ b/src/test/txvalidationcache_tests.cpp
@@ -198,4 +198,4 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
// spend_tx is invalid according to DERSIG
- CValidationState state;
{
+ CValidationState state;
PrecomputedTransactionData ptd_spend_tx(spend_tx); |
46d53a6 to
855adc6
Compare
Contributor
Author
|
Combined/correct fix used instead. |
promag
reviewed
Jul 8, 2017
src/test/txvalidationcache_tests.cpp
Outdated
src/test/txvalidationcache_tests.cpp
Outdated
src/test/txvalidationcache_tests.cpp
Outdated
Contributor
Author
There was a problem hiding this comment.
You mean with unchanged indentation? Or?
855adc6 to
5618b7d
Compare
Contributor
|
Obvious ACK 5618b7d. |
Contributor
|
Please rename PR and commit before merge. |
state, reuse it as in other cases.state
statestate down where it is used
Member
|
utACK 5618b7d |
1 similar comment
Contributor
|
utACK 5618b7d |
state down where it is usedstate down where it is used
Member
|
utACK 5618b7d |
maflcko
pushed a commit
that referenced
this pull request
Jul 16, 2017
5618b7d Do not shadow upper local variable `state`. (Pavel Janík) Pull request description: Tests added in #10192 emit few shadowing warnings: ``` test/txvalidationcache_tests.cpp:268:26: warning: declaration shadows a local variable [-Wshadow] test/txvalidationcache_tests.cpp:296:26: warning: declaration shadows a local variable [-Wshadow] test/txvalidationcache_tests.cpp:357:26: warning: declaration shadows a local variable [-Wshadow] ``` Remove shadowing declarations and reuse the upper local declaration as in other already present test cases. Tree-SHA512: 1e3c52cf963f8f33e729900c8ecdcd5cc6fe28caa441ba53c4636df9cc3d1a351ca231966d36384589f1340ae8ddd447424c2ee3e8527d334d0412f0d1a10c8f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tests added in #10192 emit few shadowing warnings:
Remove shadowing declarations and reuse the upper local declaration as in other already present test cases.