diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -25,7 +25,9 @@ uint32_t n; public: - COutPoint() : txid(), n(-1) {} + static constexpr uint32_t NULL_INDEX = std::numeric_limits::max(); + + COutPoint() : txid(), n(NULL_INDEX) {} COutPoint(TxId txidIn, uint32_t nIn) : txid(txidIn), n(nIn) {} ADD_SERIALIZE_METHODS; @@ -36,7 +38,7 @@ READWRITE(n); } - bool IsNull() const { return txid.IsNull() && n == uint32_t(-1); } + bool IsNull() const { return txid.IsNull() && n == NULL_INDEX; } const TxId &GetTxId() const { return txid; } uint32_t GetN() const { return n; } diff --git a/src/streams.h b/src/streams.h --- a/src/streams.h +++ b/src/streams.h @@ -746,7 +746,8 @@ CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn), nSrcPos(0), nReadPos(0), - nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0) { + nReadLimit(std::numeric_limits::max()), nRewind(nRewindIn), + vchBuf(nBufSize, 0) { src = fileIn; } @@ -828,7 +829,7 @@ } // Prevent reading beyond a certain position. No argument removes the limit. - bool SetLimit(uint64_t nPos = (uint64_t)(-1)) { + bool SetLimit(uint64_t nPos = std::numeric_limits::max()) { if (nPos < nReadPos) { return false; } diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -206,7 +206,7 @@ } for (uint64_t i = 0; i < 100000000000ULL; i += 999999937) { - uint64_t j = -1; + uint64_t j = std::numeric_limits::max(); ss >> VARINT(j); BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i); }