Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,58 @@ if test "x$enable_werror" = "xyes"; then
[AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])])
AX_CHECK_COMPILE_FLAG([-Werror=unreachable-code-loop-increment],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=mismatched-tags], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=mismatched-tags"], [], [$CXXFLAG_WERROR])
AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=null-dereference"], [], [$CXXFLAG_WERROR])
AX_CHECK_COMPILE_FLAG([-Werror=unused], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused"], [], [$CXXFLAG_WERROR])
AX_CHECK_COMPILE_FLAG([-Werror=misleading-indentation], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=misleading-indentation"], [], [$CXXFLAG_WERROR])

# Additional flags from -Wall
AX_CHECK_COMPILE_FLAG([-Werror=address],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=address"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=bool-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=bool-compare"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=catch-value],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=catch-value"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=char-subscripts],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=char-subscripts"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=comment],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=comment"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=format],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=format"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=init-self],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=init-self"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=logical-not-parentheses],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=logical-not-parentheses"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=maybe-uninitialized"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=misleading-indentation],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=misleading-indentation"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=mismatched-dealloc],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=mismatched-dealloc"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=mismatched-new-delete],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=mismatched-new-delete"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=nonnull],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=nonnull"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=narrowing],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=narrowing"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=parentheses],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=parentheses"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=pointer-sign],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=pointer-sign"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=range-loop-construct],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=range-loop-construct"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=self-move],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=self-move"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=sequence-point],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sequence-point"],,[[$CXXFLAG_WERROR]])
#AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=strict-aliasing],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=strict-aliasing"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=tautological-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=tautological-compare"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=uninitialized"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=unknown-pragmas],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unknown-pragmas"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=unused-function],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-function"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=unused-label],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-label"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=unused-value],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-value"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=volatile-register-var],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=volatile-register-var"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=zero-length-bounds],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=zero-length-bounds"],,[[$CXXFLAG_WERROR]])

# Additional flags from -Wextra
AX_CHECK_COMPILE_FLAG([-Werror=clobbered],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=clobbered"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=cast-function-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=cast-function-type"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=deprecated-copy],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=deprecated-copy"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=empty-body],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=empty-body"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=ignored-qualifiers],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=ignored-qualifiers"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=implicit-fallthrough=3],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=implicit-fallthrough=3"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=missing-field-initializers],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=missing-field-initializers"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=override-init],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=override-init"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=string-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=string-compare"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=redundant-move],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=redundant-move"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=type-limits],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=type-limits"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=uninitialized"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=shift-negative-value],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=shift-negative-value"],,[[$CXXFLAG_WERROR]])
#AX_CHECK_COMPILE_FLAG([-Werror=unused-parameter],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-parameter"],,[[$CXXFLAG_WERROR]])
#AX_CHECK_COMPILE_FLAG([-Werror=unused-but-set-parameter],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-but-set-parameter"],,[[$CXXFLAG_WERROR]])

fi

if test "x$CXXFLAGS_overridden" = "xno"; then
Expand Down
3 changes: 1 addition & 2 deletions src/coinjoin/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
{
private:
CWallet& m_wallet;
CJClientManager& m_clientman;
CCoinJoinClientManager& m_manager;

const CMasternodeSync& m_mn_sync;
Expand Down Expand Up @@ -166,7 +165,7 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
public:
explicit CCoinJoinClientSession(CWallet& pwallet, CJClientManager& clientman, const CMasternodeSync& mn_sync,
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
m_wallet(pwallet), m_clientman(clientman), m_manager(*Assert(clientman.Get(pwallet))), m_mn_sync(mn_sync), m_queueman(queueman) {}
m_wallet(pwallet), m_manager(*Assert(clientman.Get(pwallet))), m_mn_sync(mn_sync), m_queueman(queueman) {}

void ProcessMessage(CNode& peer, PeerManager& peerman, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv);

Expand Down
2 changes: 1 addition & 1 deletion src/coinjoin/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
CJContext::CJContext(CChainState& chainstate, CConnman& connman, CTxMemPool& mempool, const CMasternodeSync& mn_sync, bool relay_txes) :
#ifdef ENABLE_WALLET
clientman {
[&]() -> CJClientManager* const {
[&]() -> CJClientManager* {
assert(::coinJoinClientManagers == nullptr);
::coinJoinClientManagers = std::make_unique<CJClientManager>(connman, mempool, mn_sync, queueman);
return ::coinJoinClientManagers.get();
Expand Down
3 changes: 2 additions & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
str += "[error]";
return str;
}
if (0 <= opcode && opcode <= OP_PUSHDATA4) {
static_assert(std::numeric_limits<decltype(opcode)>::min() == 0);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check this one,isn't it doing the same? https://en.cppreference.com/w/cpp/types/is_unsigned

Suggested change
static_assert(std::numeric_limits<decltype(opcode)>::min() == 0);
static_assert(std::is_unsigned<decltype(opcode)>::value);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like, yes it is, but I wanted a 1 for 1 for the runtime check just done at compile time; they will evaluate the same for all normal integer types; idk 🤷‍♂️

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's constexpr since C++17, so, should work for any type:

template< class T >
inline constexpr bool is_unsigned_v = is_unsigned<T>::value;

which elsee runtime checks do you mean?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for sure it's constexpr, but the runtime check I'm removing is specifically 0 <= opcode and the most intuitive way imo to say that's always true is to say the min is 0; but honestly using the unsigned is probably appropriate too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually interesting it seems that static_assert(std::is_unsigned_v<decltype(opcode)>); fails as opcodetype is an enum and I guess enums aren't considered unsigned?

if (opcode <= OP_PUSHDATA4) {
if (vch.size() <= static_cast<std::vector<unsigned char>::size_type>(4)) {
str += strprintf("%d", CScriptNum(vch, false).getint());
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,22 +238,22 @@ class CDeterministicMNList

[[nodiscard]] size_t GetValidMNsCount() const
{
return ranges::count_if(mnMap, [this](const auto& p){ return IsMNValid(*p.second); });
return ranges::count_if(mnMap, [](const auto& p){ return IsMNValid(*p.second); });
}

[[nodiscard]] size_t GetAllEvoCount() const
{
return ranges::count_if(mnMap, [this](const auto& p) { return p.second->nType == MnType::Evo; });
return ranges::count_if(mnMap, [](const auto& p) { return p.second->nType == MnType::Evo; });
}

[[nodiscard]] size_t GetValidEvoCount() const
{
return ranges::count_if(mnMap, [this](const auto& p) { return p.second->nType == MnType::Evo && IsMNValid(*p.second); });
return ranges::count_if(mnMap, [](const auto& p) { return p.second->nType == MnType::Evo && IsMNValid(*p.second); });
}

[[nodiscard]] size_t GetValidWeightedMNsCount() const
{
return std::accumulate(mnMap.begin(), mnMap.end(), 0, [this](auto res, const auto& p) {
return std::accumulate(mnMap.begin(), mnMap.end(), 0, [](auto res, const auto& p) {
if (!IsMNValid(*p.second)) return res;
return res + GetMnType(p.second->nType).voting_weight;
});
Expand Down
4 changes: 2 additions & 2 deletions src/evo/dmn_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ constexpr auto Invalid = mntype_struct{

} // namespace dmn_types

[[nodiscard]] constexpr const dmn_types::mntype_struct GetMnType(MnType type)
[[nodiscard]] constexpr dmn_types::mntype_struct GetMnType(MnType type)
{
switch (type) {
case MnType::Regular: return dmn_types::Regular;
Expand All @@ -62,7 +62,7 @@ constexpr auto Invalid = mntype_struct{
}
}

[[nodiscard]] constexpr const bool IsValidMnType(MnType type)
[[nodiscard]] constexpr bool IsValidMnType(MnType type)
{
return type < MnType::COUNT;
}
Expand Down
8 changes: 4 additions & 4 deletions src/llmq/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CEvoDB& evo
const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe) :
bls_worker{std::make_shared<CBLSWorker>()},
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
quorum_block_processor{[&]() -> llmq::CQuorumBlockProcessor* const {
quorum_block_processor{[&]() -> llmq::CQuorumBlockProcessor* {
assert(llmq::quorumBlockProcessor == nullptr);
llmq::quorumBlockProcessor = std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, connman, evo_db, peerman);
return llmq::quorumBlockProcessor.get();
}()},
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, *dkg_debugman, *quorum_block_processor, sporkman, peerman, unit_tests, wipe)},
qman{[&]() -> llmq::CQuorumManager* const {
qman{[&]() -> llmq::CQuorumManager* {
assert(llmq::quorumManager == nullptr);
llmq::quorumManager = std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, *qdkgsman, evo_db, *quorum_block_processor, ::masternodeSync, peerman);
return llmq::quorumManager.get();
}()},
sigman{std::make_unique<llmq::CSigningManager>(connman, *llmq::quorumManager, peerman, unit_tests, wipe)},
shareman{std::make_unique<llmq::CSigSharesManager>(connman, *llmq::quorumManager, *sigman, peerman)},
clhandler{[&]() -> llmq::CChainLocksHandler* const {
clhandler{[&]() -> llmq::CChainLocksHandler* {
assert(llmq::chainLocksHandler == nullptr);
llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(chainstate, connman, *::masternodeSync, *llmq::quorumManager, *sigman, *shareman, sporkman, mempool, peerman);
return llmq::chainLocksHandler.get();
}()},
isman{[&]() -> llmq::CInstantSendManager* const {
isman{[&]() -> llmq::CInstantSendManager* {
assert(llmq::quorumInstantSendManager == nullptr);
llmq::quorumInstantSendManager = std::make_unique<llmq::CInstantSendManager>(*llmq::chainLocksHandler, chainstate, connman, *llmq::quorumManager, *sigman, *shareman, sporkman, mempool, *::masternodeSync, peerman, unit_tests, wipe);
return llmq::quorumInstantSendManager.get();
Expand Down
13 changes: 0 additions & 13 deletions src/node/coinstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@ static void ApplyStats(CCoinsStats& stats, const uint256& hash, const std::map<u
}
}

static void ApplyStats(CCoinsStats& stats, std::nullptr_t, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
{
assert(!outputs.empty());
stats.nTransactions++;
for (const auto& output : outputs) {
stats.nTransactionOutputs++;
if (stats.total_amount.has_value()) {
stats.total_amount = CheckedAdd(*stats.total_amount, output.second.out.nValue);
}
stats.nBogoSize += GetBogoSize(output.second.out.scriptPubKey);
}
}

//! Calculate statistics about the unspent transaction output set
template <typename T>
static bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, T hash_obj, const std::function<void()>& interruption_point, const CBlockIndex* pindex)
Expand Down
4 changes: 2 additions & 2 deletions src/qt/networkstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ static const struct {
const char *appName;
const int iconColorHueShift;
const int iconColorSaturationReduction;
const std::string titleAddText;
const std::string titleAddText = "";
} network_styles[] = {
{"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""},
{"main", QAPP_APP_NAME_DEFAULT, 0, 0},
{"test", QAPP_APP_NAME_TESTNET, 190, 20},
{"devnet", QAPP_APP_NAME_DEVNET, 190, 20, "[devnet: %s]"},
{"regtest", QAPP_APP_NAME_REGTEST, 160, 30}
Expand Down
3 changes: 2 additions & 1 deletion src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
if (opcode == OP_CODESEPARATOR && sigversion == SigVersion::BASE && (flags & SCRIPT_VERIFY_CONST_SCRIPTCODE))
return set_error(serror, SCRIPT_ERR_OP_CODESEPARATOR);

if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) {
static_assert(std::numeric_limits<std::underlying_type_t<decltype(opcode)>>::min() == 0);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again std::is_unsigned

if (fExec && opcode <= OP_PUSHDATA4) {
if (fRequireMinimal && !CheckMinimalPush(vchPushValue, opcode)) {
return set_error(serror, SCRIPT_ERR_MINIMALDATA);
}
Expand Down
5 changes: 2 additions & 3 deletions src/script/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ std::vector<unsigned char> ToByteVector(const T& in)
}

/** Script opcodes */
enum opcodetype
enum opcodetype : uint8_t
{
// push value
OP_0 = 0x00,
Expand Down Expand Up @@ -430,8 +430,7 @@ class CScript : public CScriptBase

CScript& operator<<(opcodetype opcode)
{
if (opcode < 0 || opcode > 0xff)
throw std::runtime_error("CScript::operator<<(): invalid opcode");
static_assert(std::numeric_limits<std::underlying_type_t<opcodetype>>::min() == 0 && std::numeric_limits<std::underlying_type_t<opcodetype>>::max() == 0xff);
Comment thread
PastaPastaPasta marked this conversation as resolved.
Outdated
insert(end(), (unsigned char)opcode);
return *this;
}
Expand Down
11 changes: 6 additions & 5 deletions src/test/fuzz/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ bool LegacyParseInt64(const std::string& str, int64_t* out)
if (out) *out = (int64_t)n;
// Note that strtoll returns a *long long int*, so even if strtol doesn't report an over/underflow
// we still have to check that the returned value is within the range of an *int64_t*.
return endp && *endp == 0 && !errno &&
n >= std::numeric_limits<int64_t>::min() &&
n <= std::numeric_limits<int64_t>::max();
// We can assume that long long int is a 64 bit integer
static_assert(std::numeric_limits<decltype(n)>::min() == std::numeric_limits<int64_t>::min());
static_assert(std::numeric_limits<decltype(n)>::max() == std::numeric_limits<int64_t>::max());
return endp && *endp == 0 && !errno;
}

bool LegacyParseUInt32(const std::string& str, uint32_t* out)
Expand Down Expand Up @@ -117,8 +118,8 @@ bool LegacyParseUInt64(const std::string& str, uint64_t* out)
if (out) *out = (uint64_t)n;
// Note that strtoull returns a *unsigned long long int*, so even if it doesn't report an over/underflow
// we still have to check that the returned value is within the range of an *uint64_t*.
return endp && *endp == 0 && !errno &&
n <= std::numeric_limits<uint64_t>::max();
static_assert(std::numeric_limits<decltype(n)>::max() <= std::numeric_limits<uint64_t>::max());
return endp && *endp == 0 && !errno;
}

// For backwards compatibility checking.
Expand Down
2 changes: 0 additions & 2 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,6 @@ void CTxMemPool::check(CChainState& active_chainstate) const

std::list<const CTxMemPoolEntry*> waitingOnDependants;
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
unsigned int i = 0;
checkTotal += it->GetTxSize();
innerUsage += it->DynamicMemoryUsage();
const CTransaction& tx = it->GetTx();
Expand All @@ -1082,7 +1081,6 @@ void CTxMemPool::check(CChainState& active_chainstate) const
assert(it3 != mapNextTx.end());
assert(it3->first == &txin.prevout);
assert(it3->second == &tx);
i++;
}
assert(setParentCheck == GetMemPoolParents(it));
// Verify ancestor state is correct.
Expand Down