Merge bitcoin/bitcoin#23626: refactor: Fix implicit-signed-integer-truncation in cuckoocache.h

fa7da227daf8558be14f226c4366583fdc59ba10 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 fa7da227daf8558be14f226c4366583fdc59ba10

Tree-SHA512: bf2076ed94c4e80d0d29ff883080edc7a73144c73d6d3e872ec87966177ee3160f4760fc4c774aaa6fb591f4acee450a24b0f7c82291e0bef96582a6d134046e
This commit is contained in:
fanquake 2021-12-02 16:25:26 +08:00 committed by pasta
parent 2a4558b4f7
commit cd13274076
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
2 changed files with 2 additions and 3 deletions

View File

@ -91,7 +91,7 @@ public:
*/
inline void bit_set(uint32_t s)
{
mem[s >> 3].fetch_or(1 << (s & 7), std::memory_order_relaxed);
mem[s >> 3].fetch_or(uint8_t(1 << (s & 7)), std::memory_order_relaxed);
}
/** bit_unset marks an entry as something that should not be overwritten.
@ -102,7 +102,7 @@ public:
*/
inline void bit_unset(uint32_t s)
{
mem[s >> 3].fetch_and(~(1 << (s & 7)), std::memory_order_relaxed);
mem[s >> 3].fetch_and(uint8_t(~(1 << (s & 7))), std::memory_order_relaxed);
}
/** bit_is_set queries the table for discardability at `s`.

View File

@ -86,7 +86,6 @@ implicit-signed-integer-truncation:addrman.cpp
implicit-signed-integer-truncation:addrman.h
implicit-signed-integer-truncation:chain.h
implicit-signed-integer-truncation:crypto/
implicit-signed-integer-truncation:cuckoocache.h
implicit-signed-integer-truncation:leveldb/
implicit-signed-integer-truncation:miner.cpp
implicit-signed-integer-truncation:net.cpp