diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-01-17 08:48:20 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-01-17 08:48:23 +0100 |
commit | 92a71f65be7bf084ff30fe6712d5edaf1ed83364 (patch) | |
tree | 46d56bdd0dd42571bccf61a53206b69bd68bc0ce | |
parent | dfe1341c57d82d176a2f650274b551c0e652988d (diff) | |
parent | fa99e108e778b5169b3de2ce557af68f1fe0ac0b (diff) |
Merge bitcoin/bitcoin#24059: Fix implicit-integer-sign-change in arith_uint256
fa99e108e778b5169b3de2ce557af68f1fe0ac0b Fix implicit-integer-sign-change in arith_uint256 (MarcoFalke)
Pull request description:
This refactor doesn't change behaviour, but clarifies that the numbers being dealt with aren't supposed to be negative. This helps when reading the code and allows to remove a sanitizer suppression for the whole file.
ACKs for top commit:
PastaPastaPasta:
utACK fa99e108e778b5169b3de2ce557af68f1fe0ac0b
shaavan:
ACK fa99e108e778b5169b3de2ce557af68f1fe0ac0b
Tree-SHA512: f227e2fd22021e39f0445ec041f4a299d13477c23cef0fc06c53fb3313cbe550cec329336224a7e8775d9045b8009423052b394e83d42a1e40772085dfcdd471
-rw-r--r-- | src/arith_uint256.cpp | 4 | ||||
-rw-r--r-- | test/sanitizer_suppressions/ubsan | 1 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index 0bebb0cf54..f7f62dfc68 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -96,7 +96,7 @@ base_uint<BITS>& base_uint<BITS>::operator/=(const base_uint& b) while (shift >= 0) { if (num >= div) { num -= div; - pn[shift / 32] |= (1 << (shift & 31)); // set a bit of the result. + pn[shift / 32] |= (1U << (shift & 31)); // set a bit of the result. } div >>= 1; // shift back. shift--; @@ -236,7 +236,7 @@ uint32_t arith_uint256::GetCompact(bool fNegative) const nCompact >>= 8; nSize++; } - assert((nCompact & ~0x007fffff) == 0); + assert((nCompact & ~0x007fffffU) == 0); assert(nSize < 256); nCompact |= nSize << 24; nCompact |= (fNegative && (nCompact & 0x007fffff) ? 0x00800000 : 0); diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index e2195c5042..4292544dbd 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -62,7 +62,6 @@ unsigned-integer-overflow:txmempool.cpp unsigned-integer-overflow:util/strencodings.cpp unsigned-integer-overflow:validation.cpp implicit-integer-sign-change:addrman.h -implicit-integer-sign-change:arith_uint256.cpp implicit-integer-sign-change:bech32.cpp implicit-integer-sign-change:common/bloom.cpp implicit-integer-sign-change:chain.cpp |