Skip to content

Commit fa04187

Browse files
author
MarcoFalke
committed
Fix implicit-integer-sign-change in bloom
1 parent 0ff1391 commit fa04187

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/common/bloom.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void CRollingBloomFilter::insert(Span<const unsigned char> vKey)
218218
/* 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. */
219219
uint32_t pos = FastRange32(h, data.size());
220220
/* The lowest bit of pos is ignored, and set to zero for the first bit, and to one for the second. */
221-
data[pos & ~1] = (data[pos & ~1] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGeneration & 1)) << bit;
221+
data[pos & ~1U] = (data[pos & ~1U] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGeneration & 1)) << bit;
222222
data[pos | 1] = (data[pos | 1] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGeneration >> 1)) << bit;
223223
}
224224
}
@@ -230,7 +230,7 @@ bool CRollingBloomFilter::contains(Span<const unsigned char> vKey) const
230230
int bit = h & 0x3F;
231231
uint32_t pos = FastRange32(h, data.size());
232232
/* If the relevant bit is not set in either data[pos & ~1] or data[pos | 1], the filter does not contain vKey */
233-
if (!(((data[pos & ~1] | data[pos | 1]) >> bit) & 1)) {
233+
if (!(((data[pos & ~1U] | data[pos | 1]) >> bit) & 1)) {
234234
return false;
235235
}
236236
}

test/sanitizer_suppressions/ubsan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ unsigned-integer-overflow:util/strencodings.cpp
6060
unsigned-integer-overflow:validation.cpp
6161
implicit-integer-sign-change:addrman.h
6262
implicit-integer-sign-change:bech32.cpp
63-
implicit-integer-sign-change:common/bloom.cpp
6463
implicit-integer-sign-change:coins.h
6564
implicit-integer-sign-change:compat/stdin.cpp
6665
implicit-integer-sign-change:compressor.h

0 commit comments

Comments
 (0)