Skip to content

Commit 8b5a4de

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23795: refactor: Remove implicit-integer-sign-change suppressions in validation
fadd730 refactor: Remove implicit-integer-sign-change suppressions in validation.cpp (MarcoFalke) Pull request description: A file-wide suppression is problematic because it will wave through future violations, potentially bugs. Fix that by using per-statement casts. ACKs for top commit: shaavan: ACK fadd730 theStack: Code-review ACK fadd730 Tree-SHA512: a8a05613be35382b92d7970f958a4e8f4332432056eaa9d72f6719495134b93aaaeea692899d9035654d0e0cf56bcd759671eeeacfd0535582c0ea048ab58a56
2 parents 9d099b0 + fadd730 commit 8b5a4de

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/validation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,7 @@ CoinsCacheSizeState CChainState::GetCoinsCacheSizeState(
21822182
const int64_t nMempoolUsage = m_mempool ? m_mempool->DynamicMemoryUsage() : 0;
21832183
int64_t cacheSize = CoinsTip().DynamicMemoryUsage();
21842184
int64_t nTotalSpace =
2185-
max_coins_cache_size_bytes + std::max<int64_t>(max_mempool_size_bytes - nMempoolUsage, 0);
2185+
max_coins_cache_size_bytes + std::max<int64_t>(int64_t(max_mempool_size_bytes) - nMempoolUsage, 0);
21862186

21872187
//! No need to periodic flush if at least this much space still available.
21882188
static constexpr int64_t MAX_BLOCK_COINSDB_USAGE_BYTES = 10 * 1024 * 1024; // 10MB
@@ -3620,7 +3620,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, Block
36203620
// blocks which are too close in height to the tip. Apply this test
36213621
// regardless of whether pruning is enabled; it should generally be safe to
36223622
// not process unrequested blocks.
3623-
bool fTooFarAhead = (pindex->nHeight > int(m_chain.Height() + MIN_BLOCKS_TO_KEEP));
3623+
bool fTooFarAhead{pindex->nHeight > m_chain.Height() + int(MIN_BLOCKS_TO_KEEP)};
36243624

36253625
// TODO: Decouple this function from the block download logic by removing fRequested
36263626
// This requires some new chain data structure to efficiently look up if a
@@ -3842,7 +3842,7 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
38423842
return;
38433843
}
38443844

3845-
unsigned int nLastBlockWeCanPrune = std::min(prune_height, chain_tip_height - static_cast<int>(MIN_BLOCKS_TO_KEEP));
3845+
unsigned int nLastBlockWeCanPrune{(unsigned)std::min(prune_height, chain_tip_height - static_cast<int>(MIN_BLOCKS_TO_KEEP))};
38463846
uint64_t nCurrentUsage = CalculateCurrentUsage();
38473847
// We don't check to prune until after we've allocated new space for files
38483848
// So we should leave a buffer under our target to account for another allocation
@@ -4442,8 +4442,8 @@ void CChainState::LoadExternalBlockFile(FILE* fileIn, FlatFilePos* dbp)
44424442
try {
44434443
// locate a header
44444444
unsigned char buf[CMessageHeader::MESSAGE_START_SIZE];
4445-
blkdat.FindByte(m_params.MessageStart()[0]);
4446-
nRewind = blkdat.GetPos()+1;
4445+
blkdat.FindByte(char(m_params.MessageStart()[0]));
4446+
nRewind = blkdat.GetPos() + 1;
44474447
blkdat >> buf;
44484448
if (memcmp(buf, m_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE)) {
44494449
continue;

test/sanitizer_suppressions/ubsan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ implicit-integer-sign-change:test/skiplist_tests.cpp
7777
implicit-integer-sign-change:test/streams_tests.cpp
7878
implicit-integer-sign-change:test/transaction_tests.cpp
7979
implicit-integer-sign-change:txmempool.cpp
80-
implicit-integer-sign-change:validation.cpp
8180
implicit-integer-sign-change:zmq/zmqpublishnotifier.cpp
8281
implicit-signed-integer-truncation,implicit-integer-sign-change:chain.h
8382
implicit-signed-integer-truncation,implicit-integer-sign-change:test/skiplist_tests.cpp

0 commit comments

Comments
 (0)