aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-02-02 15:00:19 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-02-02 15:00:22 +0100
commit219d728fcbde8c313940788838afa46c2fb88762 (patch)
treee27c8bbf1d7545047675e097bf38d0548430861a /src
parenta41976ab770d4453ccb043f72e48a6eb15a7106a (diff)
parentfad84a25956ec081f22aebbda309d168a3dc0004 (diff)
downloadbitcoin-219d728fcbde8c313940788838afa46c2fb88762.tar.xz
Merge bitcoin/bitcoin#24219: Fix implicit-integer-sign-change in bloom
fad84a25956ec081f22aebbda309d168a3dc0004 refactor: Fixup uint64_t-cast style in touched line (MarcoFalke) fa041878de786f5be74ec74a06ec407c99ca8656 Fix implicit-integer-sign-change in bloom (MarcoFalke) Pull request description: Signed values don't really make sense when using `std::vector::operator[]`. Fix that and remove the suppression. ACKs for top commit: PastaPastaPasta: utACK fad84a25956ec081f22aebbda309d168a3dc0004 theStack: Code-review ACK fad84a25956ec081f22aebbda309d168a3dc0004 Tree-SHA512: 7139dd9aa098c41e4af1b6e63dd80e71a92b0a98062d1676b01fe550ffa8e21a5f84a578afa7a536d70dad1b8a5017625e3a9e2dda6f864b452ec77b130ddf2a
Diffstat (limited to 'src')
-rw-r--r--src/common/bloom.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/common/bloom.cpp b/src/common/bloom.cpp
index c744d05a0e..8b32a6c94a 100644
--- a/src/common/bloom.cpp
+++ b/src/common/bloom.cpp
@@ -218,8 +218,8 @@ void CRollingBloomFilter::insert(Span<const unsigned char> vKey)
/* FastMod works with the upper bits of h, so it is safe to ignore that the lower bits of h are already used for bit. */
uint32_t pos = FastRange32(h, data.size());
/* The lowest bit of pos is ignored, and set to zero for the first bit, and to one for the second. */
- data[pos & ~1] = (data[pos & ~1] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGeneration & 1)) << bit;
- data[pos | 1] = (data[pos | 1] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGeneration >> 1)) << bit;
+ data[pos & ~1U] = (data[pos & ~1U] & ~(uint64_t{1} << bit)) | (uint64_t(nGeneration & 1)) << bit;
+ data[pos | 1] = (data[pos | 1] & ~(uint64_t{1} << bit)) | (uint64_t(nGeneration >> 1)) << bit;
}
}
@@ -230,7 +230,7 @@ bool CRollingBloomFilter::contains(Span<const unsigned char> vKey) const
int bit = h & 0x3F;
uint32_t pos = FastRange32(h, data.size());
/* If the relevant bit is not set in either data[pos & ~1] or data[pos | 1], the filter does not contain vKey */
- if (!(((data[pos & ~1] | data[pos | 1]) >> bit) & 1)) {
+ if (!(((data[pos & ~1U] | data[pos | 1]) >> bit) & 1)) {
return false;
}
}