mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
bench: fixed ubsan implicit conversion
The benchmarks can now run much longer due to the minimum of 10ms or directly with -min_time. With -min_time=20000 I could trigger two ubsan errors in the benchmarks, which are fixed in this commit by using unsigned type and adding "& 0xFF".
This commit is contained in:
parent
da4e2f1da0
commit
e148a52332
@ -110,9 +110,9 @@ static void MuHash(benchmark::Bench& bench)
|
||||
{
|
||||
MuHash3072 acc;
|
||||
unsigned char key[32] = {0};
|
||||
int i = 0;
|
||||
uint32_t i = 0;
|
||||
bench.run([&] {
|
||||
key[0] = ++i;
|
||||
key[0] = ++i & 0xFF;
|
||||
acc *= MuHash3072(key);
|
||||
});
|
||||
}
|
||||
|
@ -13,16 +13,16 @@ static void RollingBloom(benchmark::Bench& bench)
|
||||
uint32_t count = 0;
|
||||
bench.run([&] {
|
||||
count++;
|
||||
data[0] = count;
|
||||
data[1] = count >> 8;
|
||||
data[2] = count >> 16;
|
||||
data[3] = count >> 24;
|
||||
data[0] = count & 0xFF;
|
||||
data[1] = (count >> 8) & 0xFF;
|
||||
data[2] = (count >> 16) & 0xFF;
|
||||
data[3] = (count >> 24) & 0xFF;
|
||||
filter.insert(data);
|
||||
|
||||
data[0] = count >> 24;
|
||||
data[1] = count >> 16;
|
||||
data[2] = count >> 8;
|
||||
data[3] = count;
|
||||
data[0] = (count >> 24) & 0xFF;
|
||||
data[1] = (count >> 16) & 0xFF;
|
||||
data[2] = (count >> 8) & 0xFF;
|
||||
data[3] = count & 0xFF;
|
||||
filter.contains(data);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user