aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-03-09 10:02:49 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-03-09 10:02:55 +0100
commitb403ec5c0f2fa0464a9d40f9d5c25beb0bd3c5df (patch)
tree5d11a82b2a63b869917a7be9bd55b0baa385d4e2
parent02bd6e9bc6de9b1ce188335b1b2f2796d18e434c (diff)
parent8e0720bdb9141b00b4c00893b8139904c67ddacf (diff)
downloadbitcoin-b403ec5c0f2fa0464a9d40f9d5c25beb0bd3c5df.tar.xz
Merge #9916: Fix msvc compiler error C4146 (minus operator applied to unsigned type)
8e0720b Fix msvc compiler error C4146 (unary minus operator applied to unsigned type) (kobake) 292112f Fix msvc compiler error C4146 (minus operator applied to unsigned type) (kobake) Tree-SHA512: 25f408daf7bf9ffe4b8b4bd62f6f6d326219189a9faf8f8c0a135c5a0cb0511af765aa2b6087a091c8863c701289bda49a2379b00cd9b10854d316a5c3fc3f8e
-rw-r--r--src/bloom.cpp4
-rw-r--r--src/test/util_tests.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/bloom.cpp b/src/bloom.cpp
index 8d47cb76e8..ac3e565721 100644
--- a/src/bloom.cpp
+++ b/src/bloom.cpp
@@ -254,8 +254,8 @@ void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey)
if (nGeneration == 4) {
nGeneration = 1;
}
- uint64_t nGenerationMask1 = -(uint64_t)(nGeneration & 1);
- uint64_t nGenerationMask2 = -(uint64_t)(nGeneration >> 1);
+ uint64_t nGenerationMask1 = 0 - (uint64_t)(nGeneration & 1);
+ uint64_t nGenerationMask2 = 0 - (uint64_t)(nGeneration >> 1);
/* Wipe old entries that used this generation number. */
for (uint32_t p = 0; p < data.size(); p += 2) {
uint64_t p1 = data[p], p2 = data[p + 1];
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index 641655621c..79d02257fa 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(test_ParseInt32)
BOOST_CHECK(ParseInt32("1234", &n) && n == 1234);
BOOST_CHECK(ParseInt32("01234", &n) && n == 1234); // no octal
BOOST_CHECK(ParseInt32("2147483647", &n) && n == 2147483647);
- BOOST_CHECK(ParseInt32("-2147483648", &n) && n == -2147483648);
+ BOOST_CHECK(ParseInt32("-2147483648", &n) && n == (-2147483647 - 1)); // (-2147483647 - 1) equals INT_MIN
BOOST_CHECK(ParseInt32("-1234", &n) && n == -1234);
// Invalid values
BOOST_CHECK(!ParseInt32("", &n));