Skip to content

Commit b25a752

Browse files
author
MarcoFalke
committed
Merge bitcoin#24146: Avoid integer sanitizer warnings in chain.o
fa83210 Avoid integer sanitizer warnings in chain.o (MarcoFalke) Pull request description: The two changes make the code more self-documenting and also allow to remove 5 file-wide suppressions for the module ACKs for top commit: PastaPastaPasta: utACK fa83210 jonatack: ACK fa83210 Tree-SHA512: d32a06099c56eed9f69130a3209f989872acc593f849528acd7746ee6caa96688cc32de37e8e59ad5d25dcb8912e341f1a43e50642dadeff6ca7624d0873ad10
2 parents 9237bda + fa83210 commit b25a752

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

src/chain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& fr
151151
if (r.bits() > 63) {
152152
return sign * std::numeric_limits<int64_t>::max();
153153
}
154-
return sign * r.GetLow64();
154+
return sign * int64_t(r.GetLow64());
155155
}
156156

157157
/** Find the last common ancestor two blocks have.

src/chain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ class CChain
475475
/** Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1. */
476476
int Height() const
477477
{
478-
return vChain.size() - 1;
478+
return int(vChain.size()) - 1;
479479
}
480480

481481
/** Set/initialize a chain with a given tip. */

test/sanitizer_suppressions/ubsan

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ shift-base:test/fuzz/crypto_diff_fuzz_chacha20.cpp
4646
unsigned-integer-overflow:addrman.cpp
4747
unsigned-integer-overflow:arith_uint256.h
4848
unsigned-integer-overflow:common/bloom.cpp
49-
unsigned-integer-overflow:chain.cpp
50-
unsigned-integer-overflow:chain.h
5149
unsigned-integer-overflow:coins.cpp
5250
unsigned-integer-overflow:compressor.cpp
5351
unsigned-integer-overflow:core_write.cpp
@@ -63,8 +61,6 @@ unsigned-integer-overflow:validation.cpp
6361
implicit-integer-sign-change:addrman.h
6462
implicit-integer-sign-change:bech32.cpp
6563
implicit-integer-sign-change:common/bloom.cpp
66-
implicit-integer-sign-change:chain.cpp
67-
implicit-integer-sign-change:chain.h
6864
implicit-integer-sign-change:coins.h
6965
implicit-integer-sign-change:compat/stdin.cpp
7066
implicit-integer-sign-change:compressor.h
@@ -79,10 +75,8 @@ implicit-integer-sign-change:serialize.h
7975
implicit-integer-sign-change:test/streams_tests.cpp
8076
implicit-integer-sign-change:txmempool.cpp
8177
implicit-integer-sign-change:zmq/zmqpublishnotifier.cpp
82-
implicit-signed-integer-truncation,implicit-integer-sign-change:chain.h
8378
implicit-signed-integer-truncation:addrman.cpp
8479
implicit-signed-integer-truncation:addrman.h
85-
implicit-signed-integer-truncation:chain.h
8680
implicit-signed-integer-truncation:crypto/
8781
implicit-unsigned-integer-truncation:crypto/
8882
shift-base:arith_uint256.cpp

0 commit comments

Comments
 (0)