diff --git a/configure.ac b/configure.ac index 6b4cba8fe284..77c8c946487f 100644 --- a/configure.ac +++ b/configure.ac @@ -404,6 +404,7 @@ if test "x$enable_werror" = "xyes"; then AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]]) dnl -Wsuggest-override is broken with GCC before 9.2 dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010 AX_CHECK_COMPILE_FLAG([-Werror=suggest-override],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=suggest-override"],,[[$CXXFLAG_WERROR]], @@ -423,6 +424,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wunused-variable],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-variable"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconditional-uninitialized"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wsign-compare],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsign-compare"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]], [AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])]) diff --git a/depends/packages/bls-dash.mk b/depends/packages/bls-dash.mk index 74f45b8f61fd..17e2f3459704 100644 --- a/depends/packages/bls-dash.mk +++ b/depends/packages/bls-dash.mk @@ -1,10 +1,10 @@ package=bls-dash -$(package)_version=1.1.0 +$(package)_version=1.2.0 $(package)_download_path=https://github.com/dashpay/bls-signatures/archive $(package)_download_file=$($(package)_version).tar.gz $(package)_file_name=$(package)-$($(package)_download_file) $(package)_build_subdir=build -$(package)_sha256_hash=276c8573104e5f18bb5b9fd3ffd49585dda5ba5f6de2de74759dda8ca5a9deac +$(package)_sha256_hash=94e49f3eaa29bc1f354cd569c00f4f4314d1c8ab4758527c248b67da9686135a $(package)_dependencies=gmp cmake $(package)_patches=gcc_alignment_cast.patch $(package)_darwin_triplet=x86_64-apple-darwin19 diff --git a/src/bls/bls_worker.cpp b/src/bls/bls_worker.cpp index 0bf5a6a34d93..c6a4745fe7d2 100644 --- a/src/bls/bls_worker.cpp +++ b/src/bls/bls_worker.cpp @@ -73,13 +73,13 @@ void CBLSWorker::Stop() workerPool.stop(true); } -bool CBLSWorker::GenerateContributions(int quorumThreshold, const BLSIdVector& ids, BLSVerificationVectorPtr& vvecRet, BLSSecretKeyVector& skSharesRet) +bool CBLSWorker::GenerateContributions(uint32_t quorumThreshold, const BLSIdVector& ids, BLSVerificationVectorPtr& vvecRet, BLSSecretKeyVector& skSharesRet) { auto svec = BLSSecretKeyVector((size_t)quorumThreshold); vvecRet = std::make_shared((size_t)quorumThreshold); skSharesRet.resize(ids.size()); - for (int i = 0; i < quorumThreshold; i++) { + for (uint32_t i = 0; i < quorumThreshold; i++) { svec[i].MakeNewKey(); } size_t batchSize = 8; diff --git a/src/bls/bls_worker.h b/src/bls/bls_worker.h index 25f137732b6e..f16670057a11 100644 --- a/src/bls/bls_worker.h +++ b/src/bls/bls_worker.h @@ -55,7 +55,7 @@ class CBLSWorker void Start(); void Stop(); - bool GenerateContributions(int threshold, const BLSIdVector& ids, BLSVerificationVectorPtr& vvecRet, BLSSecretKeyVector& skSharesRet); + bool GenerateContributions(uint32_t threshold, const BLSIdVector& ids, BLSVerificationVectorPtr& vvecRet, BLSSecretKeyVector& skSharesRet); // The following functions are all used to aggregate verification (public key) vectors // Inputs are in the following form: diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index 53fcda8b5264..ca99ed4d8092 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -1010,8 +1010,8 @@ CDeterministicMNCPtr CCoinJoinClientManager::GetRandomNotUsedMasternode() { auto mnList = deterministicMNManager->GetListAtChainTip(); - size_t nCountEnabled = mnList.GetValidMNsCount(); - size_t nCountNotExcluded = nCountEnabled - vecMasternodesUsed.size(); + int nCountEnabled = mnList.GetValidMNsCount(); + int nCountNotExcluded = nCountEnabled - vecMasternodesUsed.size(); LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::%s -- %d enabled masternodes, %d masternodes to choose from\n", __func__, nCountEnabled, nCountNotExcluded); if (nCountNotExcluded < 1) { @@ -1340,7 +1340,7 @@ bool CCoinJoinClientSession::PrepareDenominate(int nMinRounds, int nMaxRounds, s // NOTE: No need to randomize order of inputs because they were // initially shuffled in CWallet::SelectTxDSInsByDenomination already. - int nSteps{0}; + uint64_t nSteps{0}; vecPSInOutPairsRet.clear(); // Try to add up to COINJOIN_ENTRY_MAX_SIZE of every needed denomination diff --git a/src/coinjoin/coinjoin.cpp b/src/coinjoin/coinjoin.cpp index de7bac827b22..bd56178654a6 100644 --- a/src/coinjoin/coinjoin.cpp +++ b/src/coinjoin/coinjoin.cpp @@ -128,7 +128,7 @@ bool CCoinJoinBroadcastTx::IsValidStructure() const if (tx->vin.size() != tx->vout.size()) { return false; } - if (tx->vin.size() < CCoinJoin::GetMinPoolParticipants()) { + if (tx->vin.size() < static_cast(CCoinJoin::GetMinPoolParticipants())) { return false; } if (tx->vin.size() > CCoinJoin::GetMaxPoolParticipants() * COINJOIN_ENTRY_MAX_SIZE) { diff --git a/src/coinjoin/coinjoin.h b/src/coinjoin/coinjoin.h index 1f9bb07a27b0..d012c22db6ff 100644 --- a/src/coinjoin/coinjoin.h +++ b/src/coinjoin/coinjoin.h @@ -369,7 +369,7 @@ class CCoinJoinBaseSession int GetState() const { return nState; } std::string GetStateString() const; - int GetEntriesCount() const { LOCK(cs_coinjoin); return vecEntries.size(); } + size_t GetEntriesCount() const { LOCK(cs_coinjoin); return vecEntries.size(); } }; // base class diff --git a/src/coinjoin/server.cpp b/src/coinjoin/server.cpp index 419a0487649d..f687abbca245 100644 --- a/src/coinjoin/server.cpp +++ b/src/coinjoin/server.cpp @@ -282,7 +282,7 @@ void CCoinJoinServer::CheckPool(CConnman& connman) // Check for Time Out // If we timed out while accepting entries, then if we have more than minimum, create final tx if (nState == POOL_STATE_ACCEPTING_ENTRIES && CCoinJoinServer::HasTimedOut() - && GetEntriesCount() >= CCoinJoin::GetMinPoolParticipants()) { + && GetEntriesCount() >= static_cast(CCoinJoin::GetMinPoolParticipants())) { // Punish misbehaving participants ChargeFees(connman); // Try to complete this session ignoring the misbehaving ones @@ -307,7 +307,7 @@ void CCoinJoinServer::CreateFinalTransaction(CConnman& connman) CMutableTransaction txNew; // make our new transaction - for (int i = 0; i < GetEntriesCount(); i++) { + for (size_t i = 0; i < GetEntriesCount(); i++) { for (const auto& txout : vecEntries[i].vecTxOut) { txNew.vout.push_back(txout); } @@ -432,10 +432,10 @@ void CCoinJoinServer::ChargeFees(CConnman& connman) const if (vecOffendersCollaterals.empty()) return; //mostly offending? Charge sometimes - if ((int)vecOffendersCollaterals.size() >= vecSessionCollaterals.size() - 1 && GetRandInt(100) > 33) return; + if (vecOffendersCollaterals.size() >= vecSessionCollaterals.size() - 1 && GetRandInt(100) > 33) return; //everyone is an offender? That's not right - if ((int)vecOffendersCollaterals.size() >= vecSessionCollaterals.size()) return; + if (vecOffendersCollaterals.size() >= vecSessionCollaterals.size()) return; //charge one of the offenders randomly Shuffle(vecOffendersCollaterals.begin(), vecOffendersCollaterals.end(), FastRandomContext()); @@ -667,7 +667,7 @@ bool CCoinJoinServer::AddScriptSig(const CTxIn& txinNew) LogPrint(BCLog::COINJOIN, "CCoinJoinServer::AddScriptSig -- adding to finalMutableTransaction, scriptSig=%s\n", ScriptToAsmStr(txinNew.scriptSig).substr(0, 24)); } } - for (int i = 0; i < GetEntriesCount(); i++) { + for (size_t i = 0; i < GetEntriesCount(); i++) { if (vecEntries[i].AddScriptSig(txinNew)) { LogPrint(BCLog::COINJOIN, "CCoinJoinServer::AddScriptSig -- adding to entries, scriptSig=%s\n", ScriptToAsmStr(txinNew.scriptSig).substr(0, 24)); return true; diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp index e001f4d2b53e..6030659069dc 100644 --- a/src/evo/cbtx.cpp +++ b/src/evo/cbtx.cpp @@ -215,7 +215,7 @@ bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPre auto qcHash = ::SerializeHash(qc.commitment); const auto& llmq_params = llmq::GetLLMQParams(qc.commitment.llmqType); auto& v = qcHashes[llmq_params.type]; - if (v.size() == llmq_params.signingActiveQuorumCount) { + if (v.size() == static_cast(llmq_params.signingActiveQuorumCount)) { // we pop the last entry, which is actually the oldest quorum as GetMinedAndActiveCommitmentsUntilBlock // returned quorums in reversed order. This pop and later push can only work ONCE, but we rely on the // fact that a block can only contain a single commitment for one LLMQ type @@ -223,7 +223,7 @@ bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPre } v.emplace_back(qcHash); hashCount++; - if (v.size() > llmq_params.signingActiveQuorumCount) { + if (v.size() > static_cast(llmq_params.signingActiveQuorumCount)) { return state.DoS(100, false, REJECT_INVALID, "excess-quorums-calc-cbtx-quorummerkleroot"); } } diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index 120f82b4d134..3af7ff352841 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -370,9 +370,9 @@ class CDeterministicMNList return mnMap.size(); } - size_t GetValidMNsCount() const + int GetValidMNsCount() const { - size_t count = 0; + int count = 0; for (const auto& p : mnMap) { if (IsMNValid(p.second)) { count++; diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index d1fd99d98aa6..8cf8691ba2e7 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -970,7 +970,7 @@ int CGovernanceManager::RequestGovernanceObjectVotes(const std::vector& int nMaxObjRequestsPerNode = 1; size_t nProjectedVotes = 2000; if (Params().NetworkIDString() != CBaseChainParams::MAIN) { - nMaxObjRequestsPerNode = std::max(1, int(nProjectedVotes / std::max(1, (int)deterministicMNManager->GetListAtChainTip().GetValidMNsCount()))); + nMaxObjRequestsPerNode = std::max(1, int(nProjectedVotes / std::max(1, deterministicMNManager->GetListAtChainTip().GetValidMNsCount()))); } { diff --git a/src/governance/object.cpp b/src/governance/object.cpp index e904ae276f67..cb8f4976460b 100644 --- a/src/governance/object.cpp +++ b/src/governance/object.cpp @@ -682,7 +682,7 @@ void CGovernanceObject::UpdateSentinelVariables() { // CALCULATE MINIMUM SUPPORT LEVELS REQUIRED - int nMnCount = (int)deterministicMNManager->GetListAtChainTip().GetValidMNsCount(); + int nMnCount = deterministicMNManager->GetListAtChainTip().GetValidMNsCount(); if (nMnCount == 0) return; // CALCULATE THE MINIMUM VOTE COUNT REQUIRED FOR FULL SIGNAL diff --git a/src/llmq/blockprocessor.cpp b/src/llmq/blockprocessor.cpp index c1831cec5568..8fc154dbb0d7 100644 --- a/src/llmq/blockprocessor.cpp +++ b/src/llmq/blockprocessor.cpp @@ -460,7 +460,7 @@ std::vector CQuorumBlockProcessor::GetMinedCommitmentsUntilB } uint32_t nMinedHeight = std::numeric_limits::max() - be32toh(std::get<2>(curKey)); - if (nMinedHeight > pindex->nHeight) { + if (nMinedHeight > static_cast(pindex->nHeight)) { break; } diff --git a/src/llmq/commitment.cpp b/src/llmq/commitment.cpp index 99fb87265132..adc904bfa806 100644 --- a/src/llmq/commitment.cpp +++ b/src/llmq/commitment.cpp @@ -69,7 +69,7 @@ bool CFinalCommitment::Verify(const CBlockIndex* pQuorumBaseBlockIndex, bool che } auto members = CLLMQUtils::GetAllQuorumMembers(llmq_params, pQuorumBaseBlockIndex); - for (size_t i = members.size(); i < llmq_params.size; i++) { + for (size_t i = members.size(); i < static_cast(llmq_params.size); i++) { if (validMembers[i]) { LogPrintfFinalCommitment("invalid validMembers bitset. bit %d should not be set\n", i); return false; @@ -122,11 +122,11 @@ bool CFinalCommitment::VerifyNull() const bool CFinalCommitment::VerifySizes(const Consensus::LLMQParams& params) const { - if (signers.size() != params.size) { + if (signers.size() != static_cast(params.size)) { LogPrintfFinalCommitment("invalid signers.size=%d\n", signers.size()); return false; } - if (validMembers.size() != params.size) { + if (validMembers.size() != static_cast(params.size)) { LogPrintfFinalCommitment("invalid signers.size=%d\n", signers.size()); return false; } @@ -144,7 +144,7 @@ bool CheckLLMQCommitment(const CTransaction& tx, const CBlockIndex* pindexPrev, return state.DoS(100, false, REJECT_INVALID, "bad-qc-version"); } - if (qcTx.nHeight != pindexPrev->nHeight + 1) { + if (qcTx.nHeight != static_cast(pindexPrev->nHeight + 1)) { return state.DoS(100, false, REJECT_INVALID, "bad-qc-height"); } diff --git a/src/llmq/dkgsession.cpp b/src/llmq/dkgsession.cpp index 4b64fee7d7c1..a01aacb19753 100644 --- a/src/llmq/dkgsession.cpp +++ b/src/llmq/dkgsession.cpp @@ -120,7 +120,7 @@ bool CDKGSession::Init(const CBlockIndex* _pQuorumBaseBlockIndex, const std::vec CDKGLogger logger(*this, __func__); - if (mns.size() < params.minSize) { + if (mns.size() < static_cast(params.minSize)) { logger.Batch("not enough members (%d < %d), aborting init", mns.size(), params.minSize); return false; } @@ -235,7 +235,7 @@ bool CDKGSession::PreVerifyMessage(const CDKGContribution& qc, bool& retBan) con retBan = true; return false; } - if (qc.vvec->size() != params.threshold) { + if (qc.vvec->size() != static_cast(params.threshold)) { logger.Batch("invalid verification vector length"); retBan = true; return false; @@ -655,7 +655,7 @@ void CDKGSession::VerifyAndJustify(CDKGPendingMessages& pendingMessages) if (m->bad) { continue; } - if (m->badMemberVotes.size() >= params.dkgBadVotesThreshold) { + if (m->badMemberVotes.size() >= static_cast(params.dkgBadVotesThreshold)) { logger.Batch("%s marked as bad as %d other members voted for this", m->dmn->proTxHash.ToString(), m->badMemberVotes.size()); MarkBadMember(m->idx); continue; @@ -1082,7 +1082,7 @@ bool CDKGSession::PreVerifyMessage(const CDKGPrematureCommitment& qc, bool& retB return false; } - for (size_t i = members.size(); i < params.size; i++) { + for (auto i = static_cast(members.size()); i < params.size; i++) { if (qc.validMembers[i]) { retBan = true; logger.Batch("invalid validMembers bitset. bit %d should not be set", i); @@ -1221,7 +1221,7 @@ std::vector CDKGSession::FinalizeCommitments() std::vector finalCommitments; for (const auto& p : commitmentsMap) { auto& cvec = p.second; - if (cvec.size() < params.minSize) { + if (cvec.size() < static_cast(params.minSize)) { // commitment was signed by a minority continue; } diff --git a/src/llmq/instantsend.cpp b/src/llmq/instantsend.cpp index faf205ef95e2..05210febb045 100644 --- a/src/llmq/instantsend.cpp +++ b/src/llmq/instantsend.cpp @@ -192,7 +192,7 @@ std::unordered_map CInstantSen if (!it->GetKey(curKey) || std::get<0>(curKey) != DB_MINED_BY_HEIGHT_AND_HASH) { break; } - uint32_t nHeight = std::numeric_limits::max() - be32toh(std::get<1>(curKey)); + int32_t nHeight = std::numeric_limits::max() - be32toh(std::get<1>(curKey)); if (nHeight > nUntilHeight) { break; } @@ -236,7 +236,7 @@ void CInstantSendDb::RemoveArchivedInstantSendLocks(int nUntilHeight) if (!it->GetKey(curKey) || std::get<0>(curKey) != DB_ARCHIVED_BY_HEIGHT_AND_HASH) { break; } - uint32_t nHeight = std::numeric_limits::max() - be32toh(std::get<1>(curKey)); + int32_t nHeight = std::numeric_limits::max() - be32toh(std::get<1>(curKey)); if (nHeight > nUntilHeight) { break; } diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index 93251829b069..89708764b637 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -690,7 +690,7 @@ void CQuorumManager::ProcessMessage(CNode* pFrom, const std::string& strCommand, // Check if request has ENCRYPTED_CONTRIBUTIONS data if (request.GetDataMask() & CQuorumDataRequest::ENCRYPTED_CONTRIBUTIONS) { - if (WITH_LOCK(pQuorum->cs, return pQuorum->quorumVvec->size() != pQuorum->params.threshold)) { + if (WITH_LOCK(pQuorum->cs, return pQuorum->quorumVvec->size() != static_cast(pQuorum->params.threshold))) { errorHandler("No valid quorum verification vector available", 0); // Don't bump score because we asked for it return; } diff --git a/src/llmq/signing_shares.cpp b/src/llmq/signing_shares.cpp index 97ab5f747146..719defd3cc72 100644 --- a/src/llmq/signing_shares.cpp +++ b/src/llmq/signing_shares.cpp @@ -347,7 +347,7 @@ bool CSigSharesManager::ProcessMessageSigSesAnn(const CNode* pfrom, const CSigSe bool CSigSharesManager::VerifySigSharesInv(Consensus::LLMQType llmqType, const CSigSharesInv& inv) { - return inv.inv.size() == GetLLMQParams(llmqType).size; + return inv.inv.size() == static_cast(GetLLMQParams(llmqType).size); } bool CSigSharesManager::ProcessMessageSigSharesInv(const CNode* pfrom, const CSigSharesInv& inv) @@ -748,7 +748,7 @@ void CSigSharesManager::ProcessSigShare(const CSigShare& sigShare, const CConnma } size_t sigShareCount = sigShares.CountForSignHash(sigShare.GetSignHash()); - if (sigShareCount >= quorum->params.threshold) { + if (sigShareCount >= static_cast(quorum->params.threshold)) { canTryRecovery = true; } } @@ -777,14 +777,14 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256& sigSharesForRecovery.reserve((size_t) quorum->params.threshold); idsForRecovery.reserve((size_t) quorum->params.threshold); - for (auto it = sigSharesForSignHash->begin(); it != sigSharesForSignHash->end() && sigSharesForRecovery.size() < quorum->params.threshold; ++it) { + for (auto it = sigSharesForSignHash->begin(); it != sigSharesForSignHash->end() && sigSharesForRecovery.size() < static_cast(quorum->params.threshold); ++it) { auto& sigShare = it->second; sigSharesForRecovery.emplace_back(sigShare.sigShare.Get()); idsForRecovery.emplace_back(quorum->members[sigShare.quorumMember]->proTxHash); } // check if we can recover the final signature - if (sigSharesForRecovery.size() < quorum->params.threshold) { + if (sigSharesForRecovery.size() < static_cast(quorum->params.threshold)) { return; } } @@ -822,7 +822,7 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256& CDeterministicMNCPtr CSigSharesManager::SelectMemberForRecovery(const CQuorumCPtr& quorum, const uint256 &id, int attempt) { - assert(attempt < quorum->members.size()); + assert(static_cast(attempt) < quorum->members.size()); std::vector> v; v.reserve(quorum->members.size()); diff --git a/src/masternode/utils.cpp b/src/masternode/utils.cpp index cf0abaa9fae9..03d515ee2768 100644 --- a/src/masternode/utils.cpp +++ b/src/masternode/utils.cpp @@ -24,7 +24,7 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman) #endif // ENABLE_WALLET // Don't disconnect masternode connections when we have less then the desired amount of outbound nodes - int nonMasternodeCount = 0; + size_t nonMasternodeCount = 0; connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) { if (!pnode->fInbound && !pnode->fFeeler && !pnode->m_manual_connection && !pnode->m_masternode_connection && !pnode->m_masternode_probe_connection) { nonMasternodeCount++; diff --git a/src/prevector.h b/src/prevector.h index 5b9cd0dfb3ea..fc793ec9d3aa 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -555,7 +555,7 @@ class prevector { // We know that internally the iterators are pointing to continues memory, so we can directly use the pointers here // This avoids internal use of std::copy and operator++ on the iterators and instead allows efficient memcpy/memmove if (std::is_trivially_constructible::value) { - auto s = e - b; + size_t s = e - b; if (v.size() != s) { v.resize(s); } diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 0aa06dd1ab0b..0c20d36b91a7 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -1624,7 +1624,7 @@ std::vector getSupportedWeights() return mapSupportedWeights[fontFamily]; } -QFont::Weight supportedWeightFromIndex(int nIndex) +QFont::Weight supportedWeightFromIndex(size_t nIndex) { auto vecWeights = getSupportedWeights(); assert(vecWeights.size() > nIndex); @@ -1634,7 +1634,7 @@ QFont::Weight supportedWeightFromIndex(int nIndex) int supportedWeightToIndex(QFont::Weight weight) { auto vecWeights = getSupportedWeights(); - for (int index = 0; index < vecWeights.size(); ++index) { + for (size_t index = 0; index < vecWeights.size(); ++index) { if (weight == vecWeights[index]) { return index; } diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index dd6b4a9d891e..407fe8b8913f 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -375,7 +375,7 @@ namespace GUIUtil /** Return supported weights for the current font family */ std::vector getSupportedWeights(); /** Convert an index to a weight in the supported weights vector */ - QFont::Weight supportedWeightFromIndex(int nIndex); + QFont::Weight supportedWeightFromIndex(size_t nIndex); /** Convert a weight to an index in the supported weights vector */ int supportedWeightToIndex(QFont::Weight weight); /** Check if a weight is supported by the current font family */ diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 602f0b754aee..0d72324ee029 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -439,7 +439,7 @@ static UniValue masternode_payments(const JSONRPCRequest& request) // A temporary vector which is used to sort results properly (there is no "reverse" in/for UniValue) std::vector vecPayments; - while (vecPayments.size() < std::abs(nCount) && pindex != nullptr) { + while (vecPayments.size() < static_cast(std::abs(nCount)) && pindex != nullptr) { CBlock block; if (!ReadBlockFromDisk(block, pindex, Params().GetConsensus())) { diff --git a/src/serialize.h b/src/serialize.h index 719c7890ee82..05f387823412 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -509,12 +509,12 @@ void ReadFixedVarIntsBitSet(Stream& s, std::vector& vec, size_t size) int32_t last = -1; while(true) { - uint32_t offset = ReadVarInt(s); + const int32_t offset = ReadVarInt(s); if (offset == 0) { break; } - int32_t idx = last + offset; - if (idx >= size) { + const int32_t idx = last + offset; + if (static_cast(idx) >= size) { throw std::ios_base::failure("out of bounds index"); } if (last != -1 && idx <= last) { diff --git a/src/stacktraces.cpp b/src/stacktraces.cpp index e81a2bce8ec6..c3614e5a9f93 100644 --- a/src/stacktraces.cpp +++ b/src/stacktraces.cpp @@ -109,7 +109,7 @@ static std::string GetExeFileName() if (len < 0) { return ""; } - if (len < buf.size()) { + if (len < static_cast(buf.size())) { return std::string(buf.begin(), buf.begin() + len); } buf.resize(buf.size() * 2); diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp index 76b5d79b27e6..cd7499eb3483 100644 --- a/src/test/blockfilter_index_tests.cpp +++ b/src/test/blockfilter_index_tests.cpp @@ -54,8 +54,8 @@ static bool CheckFilterLookups(BlockFilterIndex& filter_index, const CBlockIndex BOOST_CHECK(filter_index.LookupFilterHashRange(block_index->nHeight, block_index, filter_hashes)); - BOOST_CHECK_EQUAL(filters.size(), 1); - BOOST_CHECK_EQUAL(filter_hashes.size(), 1); + BOOST_CHECK_EQUAL(filters.size(), 1U); + BOOST_CHECK_EQUAL(filter_hashes.size(), 1U); BOOST_CHECK_EQUAL(filter.GetHash(), expected_filter.GetHash()); BOOST_CHECK_EQUAL(filter_header, expected_filter.ComputeHeader(last_header)); @@ -256,8 +256,9 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, TestChain100Setup) BOOST_CHECK(filter_index.LookupFilterRange(0, tip, filters)); BOOST_CHECK(filter_index.LookupFilterHashRange(0, tip, filter_hashes)); - BOOST_CHECK_EQUAL(filters.size(), tip->nHeight + 1); - BOOST_CHECK_EQUAL(filter_hashes.size(), tip->nHeight + 1); + assert(tip->nHeight >= 0); + BOOST_CHECK_EQUAL(filters.size(), tip->nHeight + 1U); + BOOST_CHECK_EQUAL(filter_hashes.size(), tip->nHeight + 1U); filters.clear(); filter_hashes.clear(); diff --git a/src/test/blockfilter_tests.cpp b/src/test/blockfilter_tests.cpp index 3006a009e0f2..8cee4c8f4eac 100644 --- a/src/test/blockfilter_tests.cpp +++ b/src/test/blockfilter_tests.cpp @@ -42,14 +42,14 @@ BOOST_AUTO_TEST_CASE(gcsfilter_test) BOOST_AUTO_TEST_CASE(gcsfilter_default_constructor) { GCSFilter filter; - BOOST_CHECK_EQUAL(filter.GetN(), 0); - BOOST_CHECK_EQUAL(filter.GetEncoded().size(), 1); + BOOST_CHECK_EQUAL(filter.GetN(), 0U); + BOOST_CHECK_EQUAL(filter.GetEncoded().size(), 1U); const GCSFilter::Params& params = filter.GetParams(); - BOOST_CHECK_EQUAL(params.m_siphash_k0, 0); - BOOST_CHECK_EQUAL(params.m_siphash_k1, 0); + BOOST_CHECK_EQUAL(params.m_siphash_k0, 0U); + BOOST_CHECK_EQUAL(params.m_siphash_k1, 0U); BOOST_CHECK_EQUAL(params.m_P, 0); - BOOST_CHECK_EQUAL(params.m_M, 1); + BOOST_CHECK_EQUAL(params.m_M, 1U); } BOOST_AUTO_TEST_CASE(blockfilter_basic_test) diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp index 9a34c4b26c5f..77a688892eb5 100644 --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -589,7 +589,7 @@ BOOST_AUTO_TEST_CASE(rolling_bloom) ++nHits; } // Expect about 100 hits - BOOST_CHECK_EQUAL(nHits, 75); + BOOST_CHECK_EQUAL(nHits, 75U); BOOST_CHECK(rb1.contains(data[DATASIZE-1])); rb1.reset(); @@ -617,7 +617,7 @@ BOOST_AUTO_TEST_CASE(rolling_bloom) ++nHits; } // Expect about 5 false positives - BOOST_CHECK_EQUAL(nHits, 6); + BOOST_CHECK_EQUAL(nHits, 6U); // last-1000-entry, 0.01% false positive: CRollingBloomFilter rb2(1000, 0.001); diff --git a/src/test/flatfile_tests.cpp b/src/test/flatfile_tests.cpp index 740d805ccedb..d53f800f6bf4 100644 --- a/src/test/flatfile_tests.cpp +++ b/src/test/flatfile_tests.cpp @@ -93,16 +93,16 @@ BOOST_AUTO_TEST_CASE(flatfile_allocate) bool out_of_space; - BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 0), 1, out_of_space), 100); - BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 0))), 100); + BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 0), 1, out_of_space), 100U); + BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 0))), 100U); BOOST_CHECK(!out_of_space); - BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 99), 1, out_of_space), 0); - BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 99))), 100); + BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 99), 1, out_of_space), 0U); + BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 99))), 100U); BOOST_CHECK(!out_of_space); - BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 99), 2, out_of_space), 101); - BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 99))), 200); + BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 99), 2, out_of_space), 101U); + BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 99))), 200U); BOOST_CHECK(!out_of_space); } @@ -116,11 +116,11 @@ BOOST_AUTO_TEST_CASE(flatfile_flush) // Flush without finalize should not truncate file. seq.Flush(FlatFilePos(0, 1)); - BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 1))), 100); + BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 1))), 100U); // Flush with finalize should truncate file. seq.Flush(FlatFilePos(0, 1), true); - BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 1))), 1); + BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 1))), 1U); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp index 2eaf260e210d..61378dc66f1c 100644 --- a/src/test/netbase_tests.cpp +++ b/src/test/netbase_tests.cpp @@ -520,7 +520,7 @@ BOOST_AUTO_TEST_CASE(netpermissions_test) BOOST_CHECK(NetWhitelistPermissions::TryParse("bloom,forcerelay,noban,relay,mempool@1.2.3.4/32", whitelistPermissions, error)); const auto strings = NetPermissions::ToStrings(PF_ALL); - BOOST_CHECK_EQUAL(strings.size(), 5); + BOOST_CHECK_EQUAL(strings.size(), 5U); BOOST_CHECK(std::find(strings.begin(), strings.end(), "bloomfilter") != strings.end()); BOOST_CHECK(std::find(strings.begin(), strings.end(), "forcerelay") != strings.end()); BOOST_CHECK(std::find(strings.begin(), strings.end(), "relay") != strings.end()); diff --git a/src/test/random_tests.cpp b/src/test/random_tests.cpp index 7c2fc4f2053b..2e0a3619eb61 100644 --- a/src/test/random_tests.cpp +++ b/src/test/random_tests.cpp @@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(shuffle_stat_test) } BOOST_CHECK(chi_score > 58.1411); // 99.9999% confidence interval BOOST_CHECK(chi_score < 210.275); - BOOST_CHECK_EQUAL(sum, 12000); + BOOST_CHECK_EQUAL(sum, 12000U); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp index 11417a71882b..389d3de98c69 100644 --- a/src/test/streams_tests.cpp +++ b/src/test/streams_tests.cpp @@ -73,28 +73,28 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader) std::vector vch = {1, 255, 3, 4, 5, 6}; VectorReader reader(SER_NETWORK, INIT_PROTO_VERSION, vch, 0); - BOOST_CHECK_EQUAL(reader.size(), 6); + BOOST_CHECK_EQUAL(reader.size(), 6U); BOOST_CHECK(!reader.empty()); // Read a single byte as an unsigned char. unsigned char a; reader >> a; BOOST_CHECK_EQUAL(a, 1); - BOOST_CHECK_EQUAL(reader.size(), 5); + BOOST_CHECK_EQUAL(reader.size(), 5U); BOOST_CHECK(!reader.empty()); // Read a single byte as a signed char. signed char b; reader >> b; BOOST_CHECK_EQUAL(b, -1); - BOOST_CHECK_EQUAL(reader.size(), 4); + BOOST_CHECK_EQUAL(reader.size(), 4U); BOOST_CHECK(!reader.empty()); // Read a 4 bytes as an unsigned int. unsigned int c; reader >> c; - BOOST_CHECK_EQUAL(c, 100992003); // 3,4,5,6 in little-endian base-256 - BOOST_CHECK_EQUAL(reader.size(), 0); + BOOST_CHECK_EQUAL(c, 100992003U); // 3,4,5,6 in little-endian base-256 + BOOST_CHECK_EQUAL(reader.size(), 0U); BOOST_CHECK(reader.empty()); // Reading after end of byte vector throws an error. @@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader) VectorReader new_reader(SER_NETWORK, INIT_PROTO_VERSION, vch, 0); new_reader >> d; BOOST_CHECK_EQUAL(d, 67370753); // 1,255,3,4 in little-endian base-256 - BOOST_CHECK_EQUAL(new_reader.size(), 2); + BOOST_CHECK_EQUAL(new_reader.size(), 2U); BOOST_CHECK(!new_reader.empty()); // Reading after end of byte vector throws an error even if the reader is @@ -148,14 +148,14 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer) BOOST_CHECK_EQUAL(serialized_int2, (uint16_t)0x1072); // NOTE: Serialized as LE BitStreamReader bit_reader(data_copy); - BOOST_CHECK_EQUAL(bit_reader.Read(1), 0); - BOOST_CHECK_EQUAL(bit_reader.Read(2), 2); - BOOST_CHECK_EQUAL(bit_reader.Read(3), 6); - BOOST_CHECK_EQUAL(bit_reader.Read(4), 11); - BOOST_CHECK_EQUAL(bit_reader.Read(5), 1); - BOOST_CHECK_EQUAL(bit_reader.Read(6), 32); - BOOST_CHECK_EQUAL(bit_reader.Read(7), 7); - BOOST_CHECK_EQUAL(bit_reader.Read(16), 30497); + BOOST_CHECK_EQUAL(bit_reader.Read(1), 0U); + BOOST_CHECK_EQUAL(bit_reader.Read(2), 2U); + BOOST_CHECK_EQUAL(bit_reader.Read(3), 6U); + BOOST_CHECK_EQUAL(bit_reader.Read(4), 11U); + BOOST_CHECK_EQUAL(bit_reader.Read(5), 1U); + BOOST_CHECK_EQUAL(bit_reader.Read(6), 32U); + BOOST_CHECK_EQUAL(bit_reader.Read(7), 7U); + BOOST_CHECK_EQUAL(bit_reader.Read(16), 30497U); BOOST_CHECK_THROW(bit_reader.Read(8), std::ios_base::failure); } @@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file) BOOST_CHECK_EQUAL(i, 1); // After reading bytes 0 and 1, we're positioned at 2. - BOOST_CHECK_EQUAL(bf.GetPos(), 2); + BOOST_CHECK_EQUAL(bf.GetPos(), 2U); // Rewind to offset 0, ok (within the 10 byte window). BOOST_CHECK(bf.SetPos(0)); @@ -275,18 +275,18 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file) // The default argument removes the limit completely. BOOST_CHECK(bf.SetLimit()); // The read position should still be at 3 (no change). - BOOST_CHECK_EQUAL(bf.GetPos(), 3); + BOOST_CHECK_EQUAL(bf.GetPos(), 3U); // Read from current offset, 3, forward until position 10. for (uint8_t j = 3; j < 10; ++j) { bf >> i; BOOST_CHECK_EQUAL(i, j); } - BOOST_CHECK_EQUAL(bf.GetPos(), 10); + BOOST_CHECK_EQUAL(bf.GetPos(), 10U); // We're guaranteed (just barely) to be able to rewind to zero. BOOST_CHECK(bf.SetPos(0)); - BOOST_CHECK_EQUAL(bf.GetPos(), 0); + BOOST_CHECK_EQUAL(bf.GetPos(), 0U); bf >> i; BOOST_CHECK_EQUAL(i, 0); @@ -296,12 +296,12 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file) BOOST_CHECK(bf.SetPos(10)); bf >> i; BOOST_CHECK_EQUAL(i, 10); - BOOST_CHECK_EQUAL(bf.GetPos(), 11); + BOOST_CHECK_EQUAL(bf.GetPos(), 11U); // Now it's only guaranteed that we can rewind to offset 1 // (current read position, 11, minus rewind amount, 10). BOOST_CHECK(bf.SetPos(1)); - BOOST_CHECK_EQUAL(bf.GetPos(), 1); + BOOST_CHECK_EQUAL(bf.GetPos(), 1U); bf >> i; BOOST_CHECK_EQUAL(i, 1); @@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file) BOOST_CHECK_EQUAL(a[j], 11 + j); } } - BOOST_CHECK_EQUAL(bf.GetPos(), 40); + BOOST_CHECK_EQUAL(bf.GetPos(), 40U); // We've read the entire file, the next read should throw. try { @@ -329,11 +329,11 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file) BOOST_CHECK(bf.eof()); // Still at offset 40, we can go back 10, to 30. - BOOST_CHECK_EQUAL(bf.GetPos(), 40); + BOOST_CHECK_EQUAL(bf.GetPos(), 40U); BOOST_CHECK(bf.SetPos(30)); bf >> i; BOOST_CHECK_EQUAL(i, 30); - BOOST_CHECK_EQUAL(bf.GetPos(), 31); + BOOST_CHECK_EQUAL(bf.GetPos(), 31U); // We're too far to rewind to position zero. BOOST_CHECK(!bf.SetPos(0)); diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index afbe6a089a7e..45afb26e01aa 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1278,24 +1278,24 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector) BOOST_CHECK(t3.origin == &t3); auto v1 = Vector(t1); - BOOST_CHECK_EQUAL(v1.size(), 1); + BOOST_CHECK_EQUAL(v1.size(), 1U); BOOST_CHECK(v1[0].origin == &t1); BOOST_CHECK_EQUAL(v1[0].copies, 1); auto v2 = Vector(std::move(t2)); - BOOST_CHECK_EQUAL(v2.size(), 1); + BOOST_CHECK_EQUAL(v2.size(), 1U); BOOST_CHECK(v2[0].origin == &t2); BOOST_CHECK_EQUAL(v2[0].copies, 0); auto v3 = Vector(t1, std::move(t2)); - BOOST_CHECK_EQUAL(v3.size(), 2); + BOOST_CHECK_EQUAL(v3.size(), 2U); BOOST_CHECK(v3[0].origin == &t1); BOOST_CHECK(v3[1].origin == &t2); BOOST_CHECK_EQUAL(v3[0].copies, 1); BOOST_CHECK_EQUAL(v3[1].copies, 0); auto v4 = Vector(std::move(v3[0]), v3[1], std::move(t3)); - BOOST_CHECK_EQUAL(v4.size(), 3); + BOOST_CHECK_EQUAL(v4.size(), 3U); BOOST_CHECK(v4[0].origin == &t1); BOOST_CHECK(v4[1].origin == &t2); BOOST_CHECK(v4[2].origin == &t3); @@ -1304,7 +1304,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector) BOOST_CHECK_EQUAL(v4[2].copies, 0); auto v5 = Cat(v1, v4); - BOOST_CHECK_EQUAL(v5.size(), 4); + BOOST_CHECK_EQUAL(v5.size(), 4U); BOOST_CHECK(v5[0].origin == &t1); BOOST_CHECK(v5[1].origin == &t1); BOOST_CHECK(v5[2].origin == &t2); @@ -1315,7 +1315,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector) BOOST_CHECK_EQUAL(v5[3].copies, 1); auto v6 = Cat(std::move(v1), v3); - BOOST_CHECK_EQUAL(v6.size(), 3); + BOOST_CHECK_EQUAL(v6.size(), 3U); BOOST_CHECK(v6[0].origin == &t1); BOOST_CHECK(v6[1].origin == &t1); BOOST_CHECK(v6[2].origin == &t2); @@ -1324,7 +1324,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector) BOOST_CHECK_EQUAL(v6[2].copies, 1); auto v7 = Cat(v2, std::move(v4)); - BOOST_CHECK_EQUAL(v7.size(), 4); + BOOST_CHECK_EQUAL(v7.size(), 4U); BOOST_CHECK(v7[0].origin == &t2); BOOST_CHECK(v7[1].origin == &t1); BOOST_CHECK(v7[2].origin == &t2); @@ -1335,7 +1335,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector) BOOST_CHECK_EQUAL(v7[3].copies, 0); auto v8 = Cat(std::move(v2), std::move(v3)); - BOOST_CHECK_EQUAL(v8.size(), 3); + BOOST_CHECK_EQUAL(v8.size(), 3U); BOOST_CHECK(v8[0].origin == &t2); BOOST_CHECK(v8[1].origin == &t1); BOOST_CHECK(v8[2].origin == &t2); diff --git a/src/test/util_threadnames_tests.cpp b/src/test/util_threadnames_tests.cpp index 32a51e34e1b8..dc6a0c4ecab4 100644 --- a/src/test/util_threadnames_tests.cpp +++ b/src/test/util_threadnames_tests.cpp @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded) std::set names = RenameEnMasse(100); - BOOST_CHECK_EQUAL(names.size(), 100); + BOOST_CHECK_EQUAL(names.size(), 100U); // Names "test_thread.[n]" should exist for n = [0, 99] for (int i = 0; i < 100; ++i) { diff --git a/src/util/system.cpp b/src/util/system.cpp index 79d26815fa3a..33a3d5c70f13 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -1235,7 +1235,7 @@ void RenameThreadPool(ctpl::thread_pool& tp, const char* baseName) // `doneCnt` should be at least `futures.size()` if tp size was increased (for whatever reason), // or at least `tp.size()` if tp size was decreased and queue was cleared // (which can happen on `stop()` if we were not fast enough to get all jobs to their threads). - } while (doneCnt < futures.size() && doneCnt < tp.size()); + } while (doneCnt < static_cast(futures.size()) && doneCnt < tp.size()); cond->notify_all(); diff --git a/src/validation.cpp b/src/validation.cpp index 1d5f35dcae6f..0969d75c437f 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -146,7 +146,7 @@ bool fPruneMode = false; bool fRequireStandard = true; bool fCheckBlockIndex = false; bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED; -size_t nCoinCacheUsage = 5000 * 300; +int64_t nCoinCacheUsage = 5000 * 300; uint64_t nPruneTarget = 0; int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; @@ -4653,7 +4653,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, } } // check level 3: check for inconsistencies during memory-only disconnect of tip blocks - if (nCheckLevel >= 3 && (coins.DynamicMemoryUsage() + ::ChainstateActive().CoinsTip().DynamicMemoryUsage()) <= nCoinCacheUsage) { + if (nCheckLevel >= 3 && (coins.DynamicMemoryUsage() + ::ChainstateActive().CoinsTip().DynamicMemoryUsage()) <= static_cast(nCoinCacheUsage)) { assert(coins.GetBestBlock() == pindex->GetBlockHash()); DisconnectResult res = ::ChainstateActive().DisconnectBlock(block, pindex, coins); if (res == DISCONNECT_FAILED) { diff --git a/src/validation.h b/src/validation.h index 949b07c9533a..3763cbaec655 100644 --- a/src/validation.h +++ b/src/validation.h @@ -143,7 +143,7 @@ extern bool g_parallel_script_checks; extern bool fRequireStandard; extern bool fCheckBlockIndex; extern bool fCheckpointsEnabled; -extern size_t nCoinCacheUsage; +extern int64_t nCoinCacheUsage; /** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */ extern CFeeRate minRelayTxFee; /** Absolute maximum transaction fee (in duffs) used by wallet and mempool (rejects high fee in sendrawtransaction) */ diff --git a/src/wallet/test/coinjoin_tests.cpp b/src/wallet/test/coinjoin_tests.cpp index 4a662ba61675..116cdb19e6e9 100644 --- a/src/wallet/test/coinjoin_tests.cpp +++ b/src/wallet/test/coinjoin_tests.cpp @@ -98,7 +98,7 @@ class CTransactionBuilderTestSetup : public TestChain100Setup BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, reserveKey, state)); AddTxToChain(tx->GetHash()); for (size_t n = 0; n < tx->vout.size(); ++n) { - if (nChangePosRet != -1 && n == nChangePosRet) { + if (nChangePosRet != -1 && static_cast(n) == nChangePosRet) { // Skip the change output to only return the requested coins continue; } diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index d19fb198301c..4b55e592fe70 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -592,9 +592,8 @@ class CreateTransactionTestSetup : public TestChain100Setup it->second.SetMerkleBranch(::ChainActive().Tip()->GetBlockHash(), 1); std::vector vecOutpoints; - size_t n; - for (n = 0; n < tx->vout.size(); ++n) { - if (nChangePosRet != -1 && n == nChangePosRet) { + for (size_t n = 0; n < tx->vout.size(); ++n) { + if (nChangePosRet != -1 && static_cast(n) == nChangePosRet) { // Skip the change output to only return the requested coins continue; } @@ -628,7 +627,7 @@ BOOST_FIXTURE_TEST_CASE(CreateTransactionTest, CreateTransactionTestSetup) {13, {{100001, true}}} }; assert(mapTestCases.size() == mapExpected.size()); - for (int i = 0; i < mapTestCases.size(); ++i) { + for (size_t i = 0; i < mapTestCases.size(); ++i) { if (!CreateTransaction(mapTestCases.at(i), mapExpected.at(i).first, mapExpected.at(i).second)) { std::cout << strprintf("CreateTransactionTest failed at: %d - %d\n", nTestId, i) << std::endl; } @@ -853,12 +852,12 @@ BOOST_FIXTURE_TEST_CASE(CreateTransactionTest, CreateTransactionTestSetup) // Just to create nCount output recipes to use in tests below std::vector> vecOutputEntries{{5000, false}}; - auto createOutputEntries = [&](int nCount) { + auto createOutputEntries = [&](size_t nCount) { while (vecOutputEntries.size() <= nCount) { vecOutputEntries.push_back(vecOutputEntries.back()); } if (vecOutputEntries.size() > nCount) { - int nDiff = vecOutputEntries.size() - nCount; + size_t nDiff = vecOutputEntries.size() - nCount; vecOutputEntries.erase(vecOutputEntries.begin(), vecOutputEntries.begin() + nDiff); } }; @@ -938,9 +937,9 @@ BOOST_FIXTURE_TEST_CASE(select_coins_grouped_by_addresses, ListCoinsTestingSetup { LOCK(wallet->cs_wallet); const auto& conflicts = wallet->GetConflicts(tx2->GetHash()); - BOOST_CHECK_EQUAL(conflicts.size(), 2); - BOOST_CHECK_EQUAL(conflicts.count(tx1->GetHash()), 1); - BOOST_CHECK_EQUAL(conflicts.count(tx2->GetHash()), 1); + BOOST_CHECK_EQUAL(conflicts.size(), 2U); + BOOST_CHECK_EQUAL(conflicts.count(tx1->GetHash()), 1U); + BOOST_CHECK_EQUAL(conflicts.count(tx2->GetHash()), 1U); } // Committed tx is the one that should be marked as "conflicting". diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 30f1f38031fb..44855639e0c8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3373,7 +3373,7 @@ bool CWallet::SelectCoinsGroupedByAddresses(std::vector& vecTa if(!(mine & filter)) continue; auto itTallyItem = mapTally.find(txdest); - if (nMaxOupointsPerAddress != -1 && itTallyItem != mapTally.end() && itTallyItem->second.vecInputCoins.size() >= nMaxOupointsPerAddress) continue; + if (nMaxOupointsPerAddress != -1 && itTallyItem != mapTally.end() && itTallyItem->second.vecInputCoins.size() >= static_cast(nMaxOupointsPerAddress)) continue; if(IsSpent(*locked_chain, outpoint.hash, i) || IsLockedCoin(outpoint.hash, i)) continue;