mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
test/refactor: upgrade to cppcheck 2.9 and fix warnings (#5049)
* refactor: resolve warnings thrown by cppcheck 2.9 * test: upgrade cppcheck to version 2.9
This commit is contained in:
parent
0a61b95d44
commit
ad88fab80d
@ -79,7 +79,7 @@ RUN apt-get update && apt-get install $APT_ARGS \
|
|||||||
xorriso \
|
xorriso \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ARG CPPCHECK_VERSION=2.8
|
ARG CPPCHECK_VERSION=2.9
|
||||||
RUN curl -sL "https://github.com/danmar/cppcheck/archive/${CPPCHECK_VERSION}.tar.gz" | tar -xvzf - --directory /tmp/
|
RUN curl -sL "https://github.com/danmar/cppcheck/archive/${CPPCHECK_VERSION}.tar.gz" | tar -xvzf - --directory /tmp/
|
||||||
RUN cd /tmp/cppcheck-${CPPCHECK_VERSION} && mkdir build && cd build && cmake .. && cmake --build . -j 8
|
RUN cd /tmp/cppcheck-${CPPCHECK_VERSION} && mkdir build && cd build && cmake .. && cmake --build . -j 8
|
||||||
ENV PATH "/tmp/cppcheck-${CPPCHECK_VERSION}/build/bin:${PATH}"
|
ENV PATH "/tmp/cppcheck-${CPPCHECK_VERSION}/build/bin:${PATH}"
|
||||||
|
@ -478,7 +478,7 @@ struct ContributionVerifier : public std::enable_shared_from_this<ContributionVe
|
|||||||
size_t batchIdx = 0;
|
size_t batchIdx = 0;
|
||||||
std::vector<bool> result(vvecs.size());
|
std::vector<bool> result(vvecs.size());
|
||||||
for (size_t i = 0; i < vvecs.size(); i += batchSize) {
|
for (size_t i = 0; i < vvecs.size(); i += batchSize) {
|
||||||
auto& batchState = batchStates[batchIdx++];
|
const auto& batchState = batchStates[batchIdx++];
|
||||||
for (size_t j = 0; j < batchState.count; j++) {
|
for (size_t j = 0; j < batchState.count; j++) {
|
||||||
result[batchState.start + j] = batchState.verifyResults[j] != 0;
|
result[batchState.start + j] = batchState.verifyResults[j] != 0;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
* If true, the timer is started just after construction.
|
* If true, the timer is started just after construction.
|
||||||
* Otherwise, it will not be automatically started.
|
* Otherwise, it will not be automatically started.
|
||||||
*/
|
*/
|
||||||
Timer(bool start = false);
|
explicit Timer(bool start = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
|
@ -241,7 +241,7 @@ bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPre
|
|||||||
// now add the commitments from the current block, which are not returned by GetMinedAndActiveCommitmentsUntilBlock
|
// now add the commitments from the current block, which are not returned by GetMinedAndActiveCommitmentsUntilBlock
|
||||||
// due to the use of pindexPrev (we don't have the tip index here)
|
// due to the use of pindexPrev (we don't have the tip index here)
|
||||||
for (size_t i = 1; i < block.vtx.size(); i++) {
|
for (size_t i = 1; i < block.vtx.size(); i++) {
|
||||||
auto& tx = block.vtx[i];
|
const auto& tx = block.vtx[i];
|
||||||
|
|
||||||
if (tx->nVersion == 3 && tx->nType == TRANSACTION_QUORUM_COMMITMENT) {
|
if (tx->nVersion == 3 && tx->nType == TRANSACTION_QUORUM_COMMITMENT) {
|
||||||
llmq::CFinalCommitmentTxPayload qc;
|
llmq::CFinalCommitmentTxPayload qc;
|
||||||
|
@ -19,7 +19,7 @@ inline bool GetTxPayload(const std::vector<unsigned char>& payload, T& obj)
|
|||||||
CDataStream ds(payload, SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ds(payload, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
try {
|
try {
|
||||||
ds >> obj;
|
ds >> obj;
|
||||||
} catch (std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ds.empty();
|
return ds.empty();
|
||||||
|
@ -264,7 +264,7 @@ std::set<uint256> CGovernanceObject::RemoveInvalidVotes(const COutPoint& mnOutpo
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string removedStr;
|
std::string removedStr;
|
||||||
for (auto& h : removedVotes) {
|
for (const auto& h : removedVotes) {
|
||||||
removedStr += strprintf(" %s\n", h.ToString());
|
removedStr += strprintf(" %s\n", h.ToString());
|
||||||
}
|
}
|
||||||
LogPrintf("CGovernanceObject::%s -- Removed %d invalid votes for %s from MN %s:\n%s", __func__, removedVotes.size(), nParentHash.ToString(), mnOutpoint.ToString(), removedStr); /* Continued */
|
LogPrintf("CGovernanceObject::%s -- Removed %d invalid votes for %s from MN %s:\n%s", __func__, removedVotes.size(), nParentHash.ToString(), mnOutpoint.ToString(), removedStr); /* Continued */
|
||||||
|
@ -272,7 +272,7 @@ void CQuorumManager::UpdatedBlockTip(const CBlockIndex* pindexNew, bool fInitial
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& params : Params().GetConsensus().llmqs) {
|
for (const auto& params : Params().GetConsensus().llmqs) {
|
||||||
CheckQuorumConnections(params, pindexNew);
|
CheckQuorumConnections(params, pindexNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,19 +150,19 @@ std::vector<std::vector<CDeterministicMNCPtr>> ComputeQuorumMembersByQuarterRota
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
ss << " 3Cmns[";
|
ss << " 3Cmns[";
|
||||||
for (auto &m: previousQuarters.quarterHMinus3C[i]) {
|
for (const auto &m: previousQuarters.quarterHMinus3C[i]) {
|
||||||
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
||||||
}
|
}
|
||||||
ss << " ] 2Cmns[";
|
ss << " ] 2Cmns[";
|
||||||
for (auto &m: previousQuarters.quarterHMinus2C[i]) {
|
for (const auto &m: previousQuarters.quarterHMinus2C[i]) {
|
||||||
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
||||||
}
|
}
|
||||||
ss << " ] Cmns[";
|
ss << " ] Cmns[";
|
||||||
for (auto &m: previousQuarters.quarterHMinusC[i]) {
|
for (const auto &m: previousQuarters.quarterHMinusC[i]) {
|
||||||
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
||||||
}
|
}
|
||||||
ss << " ] new[";
|
ss << " ] new[";
|
||||||
for (auto &m: newQuarterMembers[i]) {
|
for (const auto &m: newQuarterMembers[i]) {
|
||||||
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
||||||
}
|
}
|
||||||
ss << " ]";
|
ss << " ]";
|
||||||
@ -172,23 +172,23 @@ std::vector<std::vector<CDeterministicMNCPtr>> ComputeQuorumMembersByQuarterRota
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto i = 0; i < nQuorums; ++i) {
|
for (auto i = 0; i < nQuorums; ++i) {
|
||||||
for (auto &m: previousQuarters.quarterHMinus3C[i]) {
|
for (const auto &m: previousQuarters.quarterHMinus3C[i]) {
|
||||||
quorumMembers[i].push_back(std::move(m));
|
quorumMembers[i].push_back(std::move(m));
|
||||||
}
|
}
|
||||||
for (auto &m: previousQuarters.quarterHMinus2C[i]) {
|
for (const auto &m: previousQuarters.quarterHMinus2C[i]) {
|
||||||
quorumMembers[i].push_back(std::move(m));
|
quorumMembers[i].push_back(std::move(m));
|
||||||
}
|
}
|
||||||
for (auto &m: previousQuarters.quarterHMinusC[i]) {
|
for (const auto &m: previousQuarters.quarterHMinusC[i]) {
|
||||||
quorumMembers[i].push_back(std::move(m));
|
quorumMembers[i].push_back(std::move(m));
|
||||||
}
|
}
|
||||||
for (auto &m: newQuarterMembers[i]) {
|
for (const auto &m: newQuarterMembers[i]) {
|
||||||
quorumMembers[i].push_back(std::move(m));
|
quorumMembers[i].push_back(std::move(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LogAcceptCategory(BCLog::LLMQ)) {
|
if (LogAcceptCategory(BCLog::LLMQ)) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << " [";
|
ss << " [";
|
||||||
for (auto &m: quorumMembers[i]) {
|
for (const auto &m: quorumMembers[i]) {
|
||||||
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
||||||
}
|
}
|
||||||
ss << "]";
|
ss << "]";
|
||||||
@ -263,11 +263,11 @@ std::vector<std::vector<CDeterministicMNCPtr>> BuildNewQuorumQuarterMembers(cons
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
MnsUsedAtH.AddMN(mn);
|
MnsUsedAtH.AddMN(mn);
|
||||||
} catch (std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
MnsUsedAtHIndexed[i].AddMN(mn);
|
MnsUsedAtHIndexed[i].AddMN(mn);
|
||||||
} catch (std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto& mn : previousQuarters.quarterHMinus2C[i]) {
|
for (const auto& mn : previousQuarters.quarterHMinus2C[i]) {
|
||||||
@ -276,11 +276,11 @@ std::vector<std::vector<CDeterministicMNCPtr>> BuildNewQuorumQuarterMembers(cons
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
MnsUsedAtH.AddMN(mn);
|
MnsUsedAtH.AddMN(mn);
|
||||||
} catch (std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
MnsUsedAtHIndexed[i].AddMN(mn);
|
MnsUsedAtHIndexed[i].AddMN(mn);
|
||||||
} catch (std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto& mn : previousQuarters.quarterHMinus3C[i]) {
|
for (const auto& mn : previousQuarters.quarterHMinus3C[i]) {
|
||||||
@ -289,11 +289,11 @@ std::vector<std::vector<CDeterministicMNCPtr>> BuildNewQuorumQuarterMembers(cons
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
MnsUsedAtH.AddMN(mn);
|
MnsUsedAtH.AddMN(mn);
|
||||||
} catch (std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
MnsUsedAtHIndexed[i].AddMN(mn);
|
MnsUsedAtHIndexed[i].AddMN(mn);
|
||||||
} catch (std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ std::vector<std::vector<CDeterministicMNCPtr>> BuildNewQuorumQuarterMembers(cons
|
|||||||
if (!dmn->pdmnState->IsBanned()) {
|
if (!dmn->pdmnState->IsBanned()) {
|
||||||
try {
|
try {
|
||||||
MnsNotUsedAtH.AddMN(dmn);
|
MnsNotUsedAtH.AddMN(dmn);
|
||||||
} catch (std::runtime_error &e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ std::vector<std::vector<CDeterministicMNCPtr>> BuildNewQuorumQuarterMembers(cons
|
|||||||
if (LogAcceptCategory(BCLog::LLMQ)) {
|
if (LogAcceptCategory(BCLog::LLMQ)) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << " [";
|
ss << " [";
|
||||||
for (auto &m: sortedCombinedMnsList) {
|
for (const auto &m: sortedCombinedMnsList) {
|
||||||
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
||||||
}
|
}
|
||||||
ss << "]";
|
ss << "]";
|
||||||
@ -410,7 +410,7 @@ std::vector<std::vector<CDeterministicMNCPtr>> GetQuorumQuarterMembersBySnapshot
|
|||||||
if (LogAcceptCategory(BCLog::LLMQ)) {
|
if (LogAcceptCategory(BCLog::LLMQ)) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << " [";
|
ss << " [";
|
||||||
for (auto &m: sortedCombinedMns) {
|
for (const auto &m: sortedCombinedMns) {
|
||||||
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
ss << m->proTxHash.ToString().substr(0, 4) << "|";
|
||||||
}
|
}
|
||||||
ss << "]";
|
ss << "]";
|
||||||
@ -500,13 +500,13 @@ std::pair<CDeterministicMNList, CDeterministicMNList> GetMNUsageBySnapshot(Conse
|
|||||||
if (snapshot.activeQuorumMembers[i]) {
|
if (snapshot.activeQuorumMembers[i]) {
|
||||||
try {
|
try {
|
||||||
usedMNs.AddMN(dmn);
|
usedMNs.AddMN(dmn);
|
||||||
} catch (std::runtime_error &e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!dmn->pdmnState->IsBanned()) {
|
if (!dmn->pdmnState->IsBanned()) {
|
||||||
try {
|
try {
|
||||||
nonUsedMNs.AddMN(dmn);
|
nonUsedMNs.AddMN(dmn);
|
||||||
} catch (std::runtime_error &e) {
|
} catch (const std::runtime_error& e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public:
|
|||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
std::vector<CMasternodeMetaInfo> tmpMetaInfo;
|
std::vector<CMasternodeMetaInfo> tmpMetaInfo;
|
||||||
for (auto& p : metaInfos) {
|
for (const auto& p : metaInfos) {
|
||||||
tmpMetaInfo.emplace_back(*p.second);
|
tmpMetaInfo.emplace_back(*p.second);
|
||||||
}
|
}
|
||||||
s << SERIALIZATION_VERSION_STRING << tmpMetaInfo << nDsqCount;
|
s << SERIALIZATION_VERSION_STRING << tmpMetaInfo << nDsqCount;
|
||||||
|
@ -63,7 +63,7 @@ static UniValue coinjoin(const JSONRPCRequest& request)
|
|||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Mixing has been started already.");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Mixing has been started already.");
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
const NodeContext& node = EnsureNodeContext(request.context);
|
||||||
bool result = it->second->DoAutomaticDenominating(*node.connman);
|
bool result = it->second->DoAutomaticDenominating(*node.connman);
|
||||||
return "Mixing " + (result ? "started successfully" : ("start failed: " + it->second->GetStatuses().original + ", will retry"));
|
return "Mixing " + (result ? "started successfully" : ("start failed: " + it->second->GetStatuses().original + ", will retry"));
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,12 @@ static UniValue quorum_list(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
CBlockIndex* pindexTip = WITH_LOCK(cs_main, return ::ChainActive().Tip());
|
CBlockIndex* pindexTip = WITH_LOCK(cs_main, return ::ChainActive().Tip());
|
||||||
|
|
||||||
for (auto& type : llmq::utils::GetEnabledQuorumTypes(pindexTip)) {
|
for (const auto& type : llmq::utils::GetEnabledQuorumTypes(pindexTip)) {
|
||||||
const auto& llmq_params = llmq::GetLLMQParams(type);
|
const auto& llmq_params = llmq::GetLLMQParams(type);
|
||||||
UniValue v(UniValue::VARR);
|
UniValue v(UniValue::VARR);
|
||||||
|
|
||||||
auto quorums = llmq::quorumManager->ScanQuorums(type, pindexTip, count > -1 ? count : llmq_params.signingActiveQuorumCount);
|
auto quorums = llmq::quorumManager->ScanQuorums(type, pindexTip, count > -1 ? count : llmq_params.signingActiveQuorumCount);
|
||||||
for (auto& q : quorums) {
|
for (const auto& q : quorums) {
|
||||||
v.push_back(q->qc->quorumHash.ToString());
|
v.push_back(q->qc->quorumHash.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumCPtr& quorum, bool includeMem
|
|||||||
if (includeMembers) {
|
if (includeMembers) {
|
||||||
UniValue membersArr(UniValue::VARR);
|
UniValue membersArr(UniValue::VARR);
|
||||||
for (size_t i = 0; i < quorum->members.size(); i++) {
|
for (size_t i = 0; i < quorum->members.size(); i++) {
|
||||||
auto& dmn = quorum->members[i];
|
const auto& dmn = quorum->members[i];
|
||||||
UniValue mo(UniValue::VOBJ);
|
UniValue mo(UniValue::VOBJ);
|
||||||
mo.pushKV("proTxHash", dmn->proTxHash.ToString());
|
mo.pushKV("proTxHash", dmn->proTxHash.ToString());
|
||||||
mo.pushKV("service", dmn->pdmnState->addr.ToString());
|
mo.pushKV("service", dmn->pdmnState->addr.ToString());
|
||||||
@ -227,7 +227,7 @@ static UniValue quorum_dkgstatus(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
UniValue arr(UniValue::VARR);
|
UniValue arr(UniValue::VARR);
|
||||||
for (auto& ec : allConnections) {
|
for (const auto& ec : allConnections) {
|
||||||
UniValue ecj(UniValue::VOBJ);
|
UniValue ecj(UniValue::VOBJ);
|
||||||
ecj.pushKV("proTxHash", ec.ToString());
|
ecj.pushKV("proTxHash", ec.ToString());
|
||||||
if (foundConnections.count(ec)) {
|
if (foundConnections.count(ec)) {
|
||||||
|
@ -21,7 +21,7 @@ struct _StatsdClientData;
|
|||||||
|
|
||||||
class StatsdClient {
|
class StatsdClient {
|
||||||
public:
|
public:
|
||||||
StatsdClient(const std::string& host = DEFAULT_STATSD_HOST, int port = DEFAULT_STATSD_PORT, const std::string& ns = DEFAULT_STATSD_NAMESPACE);
|
explicit StatsdClient(const std::string& host = DEFAULT_STATSD_HOST, int port = DEFAULT_STATSD_PORT, const std::string& ns = DEFAULT_STATSD_NAMESPACE);
|
||||||
~StatsdClient();
|
~StatsdClient();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user