diff options
author | Jon Atack <jon@atack.com> | 2021-11-22 12:08:24 +0100 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2021-11-22 15:11:58 +0100 |
commit | ab22a71429f0f47b3c3582a303c07940aa59cd3e (patch) | |
tree | 6bfe26240ac720043c192e626cd097b036b7ea89 /src/node/interfaces.cpp | |
parent | 3a36ec83d024a1343bee8e390833eb1fd7a3705d (diff) | |
download | bitcoin-ab22a71429f0f47b3c3582a303c07940aa59cd3e.tar.xz |
refactor: cast bool to int to silence compiler warning
This fixes -Wbitwise-instead-of-logical compiler warnings:
node/interfaces.cpp:544:16: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
return FillBlock(ancestor, ancestor_out, lock, active) & FillBlock(block1, block1_out, lock, active) & FillBlock(block2, block2_out, lock, active);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&&
node/interfaces.cpp:544:16: note: cast one or both operands to int to silence this warning
node/interfaces.cpp:544:16: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
return FillBlock(ancestor, ancestor_out, lock, active) & FillBlock(block1, block1_out, lock, active) & FillBlock(block2, block2_out, lock, active);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&&
node/interfaces.cpp:544:16: note: cast one or both operands to int to silence this warning
2 warnings generated.
A similar change was recently made to libsecp in commit 16d13221
for the same reason.
Diffstat (limited to 'src/node/interfaces.cpp')
-rw-r--r-- | src/node/interfaces.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 9c2d23f839..0f24211a0e 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -540,8 +540,11 @@ public: const CBlockIndex* block2 = m_node.chainman->m_blockman.LookupBlockIndex(block_hash2); const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr; // Using & instead of && below to avoid short circuiting and leaving - // output uninitialized. - return FillBlock(ancestor, ancestor_out, lock, active) & FillBlock(block1, block1_out, lock, active) & FillBlock(block2, block2_out, lock, active); + // output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical + // compiler warnings. + return int{FillBlock(ancestor, ancestor_out, lock, active)} & + int{FillBlock(block1, block1_out, lock, active)} & + int{FillBlock(block2, block2_out, lock, active)}; } void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); } double guessVerificationProgress(const uint256& block_hash) override |