diff options
| author | MarcoFalke <[email protected]> | 2018-08-13 10:02:09 -0400 |
|---|---|---|
| committer | MarcoFalke <[email protected]> | 2018-08-13 10:02:50 -0400 |
| commit | f87d0a9d75b366445f880041c56c725f8196364e (patch) | |
| tree | c64d2f6923109e48cf06d42e1da10e2612560671 /src/bench/checkblock.cpp | |
| parent | Merge #11526: Visual Studio build configuration for Bitcoin Core (diff) | |
| parent | Don't assert(foo()) where foo has side effects (diff) | |
| download | discoin-f87d0a9d75b366445f880041c56c725f8196364e.tar.xz discoin-f87d0a9d75b366445f880041c56c725f8196364e.zip | |
Merge #13534: Don't assert(foo()) where foo() has side effects
6ad0328f1c Don't assert(foo()) where foo has side effects (practicalswift)
Pull request description:
Don't `assert(foo())` where `foo` has side effects.
From `assert(3)`:
> If the macro `NDEBUG` is defined at the moment `<assert.h>` was last included, the macro `assert()` generates no code, and hence does nothing at all.
Bitcoin currently cannot be compiled without assertions, but we shouldn't rely on that.
Tree-SHA512: 28cff0c6d1c2fb612ca58c9c94142ed01c5cfd0a2fecb8e59cdb6c270374b215d952ed3491d921d84dc1b439fa49da4f0e75e080f6adcbc6b0e08be14e54c170
Diffstat (limited to 'src/bench/checkblock.cpp')
| -rw-r--r-- | src/bench/checkblock.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp index acbb72257..6f03581c4 100644 --- a/src/bench/checkblock.cpp +++ b/src/bench/checkblock.cpp @@ -28,7 +28,8 @@ static void DeserializeBlockTest(benchmark::State& state) while (state.KeepRunning()) { CBlock block; stream >> block; - assert(stream.Rewind(sizeof(block_bench::block413567))); + bool rewound = stream.Rewind(sizeof(block_bench::block413567)); + assert(rewound); } } @@ -45,10 +46,12 @@ static void DeserializeAndCheckBlockTest(benchmark::State& state) while (state.KeepRunning()) { CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here stream >> block; - assert(stream.Rewind(sizeof(block_bench::block413567))); + bool rewound = stream.Rewind(sizeof(block_bench::block413567)); + assert(rewound); CValidationState validationState; - assert(CheckBlock(block, validationState, chainParams->GetConsensus())); + bool checked = CheckBlock(block, validationState, chainParams->GetConsensus()); + assert(checked); } } |