Skip to content

Commit 282cc0c

Browse files
committed
Merge bitcoin/bitcoin#23626: refactor: Fix implicit-signed-integer-truncation in cuckoocache.h
fa7da22 refactor: Fix implicit-signed-integer-truncation in cuckoocache.h (MarcoFalke) Pull request description: Using a file-wide suppression for this implicit truncation has several issues: * It is file-wide, thus suppressing any other (newly introduced) issues * The file doesn't compile with `-Wimplicit-int-conversion` Fix both issues by making the truncation explicit. ACKs for top commit: fanquake: ACK fa7da22 Tree-SHA512: bf2076ed94c4e80d0d29ff883080edc7a73144c73d6d3e872ec87966177ee3160f4760fc4c774aaa6fb591f4acee450a24b0f7c82291e0bef96582a6d134046e
2 parents af1067c + fa7da22 commit 282cc0c

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/cuckoocache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class bit_packed_atomic_flags
8989
*/
9090
inline void bit_set(uint32_t s)
9191
{
92-
mem[s >> 3].fetch_or(1 << (s & 7), std::memory_order_relaxed);
92+
mem[s >> 3].fetch_or(uint8_t(1 << (s & 7)), std::memory_order_relaxed);
9393
}
9494

9595
/** bit_unset marks an entry as something that should not be overwritten.
@@ -100,7 +100,7 @@ class bit_packed_atomic_flags
100100
*/
101101
inline void bit_unset(uint32_t s)
102102
{
103-
mem[s >> 3].fetch_and(~(1 << (s & 7)), std::memory_order_relaxed);
103+
mem[s >> 3].fetch_and(uint8_t(~(1 << (s & 7))), std::memory_order_relaxed);
104104
}
105105

106106
/** bit_is_set queries the table for discardability at `s`.

test/sanitizer_suppressions/ubsan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ implicit-signed-integer-truncation:addrman.cpp
8686
implicit-signed-integer-truncation:addrman.h
8787
implicit-signed-integer-truncation:chain.h
8888
implicit-signed-integer-truncation:crypto/
89-
implicit-signed-integer-truncation:cuckoocache.h
9089
implicit-signed-integer-truncation:leveldb/
9190
implicit-signed-integer-truncation:node/miner.cpp
9291
implicit-signed-integer-truncation:net.cpp

0 commit comments

Comments
 (0)