Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve most compiler warnings #1305

Merged
merged 1 commit into from
May 30, 2022
Merged
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
2 changes: 2 additions & 0 deletions src/bench/bench_defi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <memory>

/*
static const int64_t DEFAULT_BENCH_EVALUATIONS = 5;
static const char* DEFAULT_BENCH_FILTER = ".*";
static const char* DEFAULT_BENCH_SCALING = "1.0";
Expand All @@ -30,6 +31,7 @@ static void SetupBenchArgs()
gArgs.AddArg("-plot-width=<x>", strprintf("Plot width in pixel (default: %u)", DEFAULT_PLOT_WIDTH), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-plot-height=<x>", strprintf("Plot height in pixel (default: %u)", DEFAULT_PLOT_HEIGHT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
}
*/

int main(int argc, char** argv)
{
Expand Down
2 changes: 1 addition & 1 deletion src/flushablestorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ class CStorageView {
// second type of 'ReadBy' (may be 'GetBy'?)
template<typename By, typename ResultType, typename KeyType>
boost::optional<ResultType> ReadBy(KeyType const & id) const {
ResultType result;
ResultType result{};
if (ReadBy<By>(id, result))
return {result};
return {};
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/anchors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ bool ContextualValidateAnchor(const CAnchorData &anchor, CBlockIndex& anchorBloc
}

// Recreate deeper anchor depth
if (anchorCreationHeight >= Params().GetConsensus().FortCanningHeight) {
if (anchorCreationHeight >= static_cast<uint64_t>(Params().GetConsensus().FortCanningHeight)) {
timeDepth += Params().GetConsensus().mn.anchoringAdditionalTimeDepth;
while (anchorHeight > 0 && ::ChainActive()[anchorHeight]->nTime + timeDepth > anchorCreationBlock->nTime) {
--anchorHeight;
Expand Down
6 changes: 3 additions & 3 deletions src/masternodes/loan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void CLoanView::EraseDelayedDestroyScheme(const std::string& loanSchemeID)

boost::optional<CInterestRateV2> CLoanView::GetInterestRate(const CVaultId& vaultId, DCT_ID id, uint32_t height)
{
if (height >= Params().GetConsensus().FortCanningHillHeight)
if (height >= static_cast<uint32_t>(Params().GetConsensus().FortCanningHillHeight))
return ReadBy<LoanInterestV2ByVault, CInterestRateV2>(std::make_pair(vaultId, id));

if (auto rate = ReadBy<LoanInterestByVault, CInterestRate>(std::make_pair(vaultId, id)))
Expand Down Expand Up @@ -251,7 +251,7 @@ CAmount InterestPerBlock(const CInterestRateV2& rate, uint32_t height)

void CLoanView::WriteInterestRate(const std::pair<CVaultId, DCT_ID>& pair, const CInterestRateV2& rate, uint32_t height)
{
if (height >= Params().GetConsensus().FortCanningHillHeight)
if (height >= static_cast<uint32_t>(Params().GetConsensus().FortCanningHillHeight))
WriteBy<LoanInterestV2ByVault>(pair, rate);
else
WriteBy<LoanInterestByVault>(pair, ConvertInterestRateToV1(rate));
Expand Down Expand Up @@ -376,7 +376,7 @@ void DeleteInterest(CLoanView& view, const CVaultId& vaultId)

Res CLoanView::DeleteInterest(const CVaultId& vaultId, uint32_t height)
{
if (height >= Params().GetConsensus().FortCanningHillHeight)
if (height >= static_cast<uint32_t>(Params().GetConsensus().FortCanningHillHeight))
::DeleteInterest<LoanInterestV2ByVault>(*this, vaultId);
else
::DeleteInterest<LoanInterestByVault>(*this, vaultId);
Expand Down
4 changes: 2 additions & 2 deletions src/masternodes/masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ std::vector<int64_t> CMasternodesView::GetSubNodesBlockTime(const CKeyID & minte
for (uint8_t i{0}; i < SUBNODE_COUNT; ++i) {
ForEachSubNode([&](const SubNodeBlockTimeKey &key, int64_t blockTime)
{
if (height >= Params().GetConsensus().FortCanningHeight) {
if (height >= static_cast<uint32_t>(Params().GetConsensus().FortCanningHeight)) {
if (key.masternodeID == nodeId && key.subnode == i) {
times[i] = blockTime;
}
Expand Down Expand Up @@ -522,7 +522,7 @@ uint16_t CMasternodesView::GetTimelock(const uint256& nodeId, const CMasternode&
auto lastHeight = height - 1;

// Cannot expire below block count required to calculate average time
if (lastHeight < Params().GetConsensus().mn.newResignDelay) {
if (lastHeight < static_cast<uint64_t>(Params().GetConsensus().mn.newResignDelay)) {
return *timelock;
}

Expand Down
12 changes: 6 additions & 6 deletions src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
updatedToken.creationTx = token.creationTx;
updatedToken.destructionTx = token.destructionTx;
updatedToken.destructionHeight = token.destructionHeight;
if (height >= consensus.FortCanningHeight) {
if (height >= static_cast<uint32_t>(consensus.FortCanningHeight)) {
updatedToken.symbol = trim_ws(updatedToken.symbol).substr(0, CToken::MAX_TOKEN_SYMBOL_LENGTH);
}

Expand Down Expand Up @@ -1158,7 +1158,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
return Res::Err("token %s does not exist!", poolPair.idTokenB.ToString());
}

const auto symbolLength = height >= consensus.FortCanningHeight ? CToken::MAX_TOKEN_POOLPAIR_LENGTH : CToken::MAX_TOKEN_SYMBOL_LENGTH;
const auto symbolLength = height >= static_cast<uint32_t>(consensus.FortCanningHeight) ? CToken::MAX_TOKEN_POOLPAIR_LENGTH : CToken::MAX_TOKEN_SYMBOL_LENGTH;
if (pairSymbol.empty()) {
pairSymbol = trim_ws(tokenA->symbol + "-" + tokenB->symbol).substr(0, symbolLength);
} else {
Expand Down Expand Up @@ -3886,7 +3886,7 @@ Res ApplyCustomTx(CCustomCSView& mnview, const CCoinsViewCache& coins, const CTr
return res;
}
std::vector<unsigned char> metadata;
const auto metadataValidation = height >= consensus.FortCanningHeight;
const auto metadataValidation = height >= static_cast<uint32_t>(consensus.FortCanningHeight);

auto txType = GuessCustomTxType(tx, metadata, metadataValidation);
if (txType == CustomTxType::None) {
Expand Down Expand Up @@ -3928,7 +3928,7 @@ Res ApplyCustomTx(CCustomCSView& mnview, const CCoinsViewCache& coins, const CTr
}
res.code |= CustomTxErrCodes::Fatal;
}
if (height >= consensus.DakotaHeight) {
if (height >= static_cast<uint32_t>(consensus.DakotaHeight)) {
res.code |= CustomTxErrCodes::Fatal;
}
return res;
Expand Down Expand Up @@ -4216,7 +4216,7 @@ Res CPoolSwap::ExecuteSwap(CCustomCSView& view, std::vector<DCT_ID> poolIDs, boo
Res poolResult = Res::Ok();

// No composite swap allowed before Fort Canning
if (height < Params().GetConsensus().FortCanningHeight && !poolIDs.empty()) {
if (height < static_cast<uint32_t>(Params().GetConsensus().FortCanningHeight) && !poolIDs.empty()) {
poolIDs.clear();
}

Expand Down Expand Up @@ -4354,7 +4354,7 @@ Res CPoolSwap::ExecuteSwap(CCustomCSView& view, std::vector<DCT_ID> poolIDs, boo
}

// Reject if price paid post-swap above max price provided
if (height >= Params().GetConsensus().FortCanningHeight && obj.maxPrice != POOLPRICE_MAX) {
if (height >= static_cast<uint32_t>(Params().GetConsensus().FortCanningHeight) && obj.maxPrice != POOLPRICE_MAX) {
if (swapAmountResult.nValue != 0) {
const auto userMaxPrice = arith_uint256(obj.maxPrice.integer) * COIN + obj.maxPrice.fraction;
if (arith_uint256(obj.amountFrom) * COIN / swapAmountResult.nValue > userMaxPrice) {
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/poolpairs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void CPoolPairView::CalculatePoolRewards(DCT_ID const & poolId, std::function<CA
auto nextCustomRewards = begin;
auto itCustomRewards = LowerBound<ByCustomReward>(poolKey);

PoolSwapValue poolSwap;
PoolSwapValue poolSwap{};
auto nextPoolSwap = UINT_MAX;
auto poolSwapHeight = UINT_MAX;
auto itPoolSwap = LowerBound<ByPoolSwap>(poolKey);
Expand Down
13 changes: 8 additions & 5 deletions src/masternodes/rpc_accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ UniValue gettokenbalances(const JSONRPCRequest& request) {
return true;
});
auto it = totalBalances.balances.lower_bound(start);
for (int i = 0; it != totalBalances.balances.end() && i < limit; it++, i++) {
CTokenAmount bal = CTokenAmount{(*it).first, (*it).second};
for (size_t i = 0; it != totalBalances.balances.end() && i < limit; it++, i++) {
auto bal = CTokenAmount{(*it).first, (*it).second};
std::string tokenIdStr = bal.nTokenId.ToString();
if (symbol_lookup) {
auto token = mnview.GetToken(bal.nTokenId);
Expand Down Expand Up @@ -1191,10 +1191,13 @@ UniValue listaccounthistory(const JSONRPCRequest& request) {
count = limit;
searchInWallet(pwallet, account, filter,
[&](CBlockIndex const * index, CWalletTx const * pwtx) {
return txs.count(pwtx->GetHash()) || startBlock > index->nHeight || index->nHeight > maxBlockHeight;
uint32_t height = index->nHeight;
return txs.count(pwtx->GetHash()) || startBlock > height || height > maxBlockHeight;
},
[&](COutputEntry const & entry, CBlockIndex const * index, CWalletTx const * pwtx) {
if (txn != std::numeric_limits<uint32_t>::max() && index->nHeight == maxBlockHeight && pwtx->nIndex > txn ) {
uint32_t height = index->nHeight;
uint32_t nIndex = pwtx->nIndex;
if (txn != std::numeric_limits<uint32_t>::max() && height == maxBlockHeight && nIndex > txn ) {
return true;
}
auto& array = ret.emplace(index->nHeight, UniValue::VARR).first->second;
Expand Down Expand Up @@ -1563,7 +1566,7 @@ UniValue accounthistorycount(const JSONRPCRequest& request) {
if (shouldSearchInWallet) {
searchInWallet(pwallet, owner, filter,
[&](CBlockIndex const * index, CWalletTx const * pwtx) {
return txs.count(pwtx->GetHash()) || index->nHeight > currentHeight;
return txs.count(pwtx->GetHash()) || static_cast<uint32_t>(index->nHeight) > currentHeight;
},
[&count](COutputEntry const &, CBlockIndex const *, CWalletTx const *) {
++count;
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/rpc_icxorderbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ UniValue icxOrderToJSON(CICXOrderImplemetation const& order, uint8_t const statu
orderObj.pushKV("closeHeight", static_cast<int>(order.closeHeight));
if (!order.closeTx.IsNull()) orderObj.pushKV("closeTx", order.closeTx.GetHex());
}
else if (order.creationHeight + order.expiry <= pcustomcsview->GetLastHeight())
else if (order.creationHeight + order.expiry <= static_cast<uint32_t>(pcustomcsview->GetLastHeight()))
{
orderObj.pushKV("expired", true);
}
Expand Down
3 changes: 1 addition & 2 deletions src/masternodes/rpc_loan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ UniValue getinterest(const JSONRPCRequest& request) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Token %s does not exist!", tokenStr));

UniValue ret(UniValue::VARR);
uint32_t height = ::ChainActive().Height() + 1;
const auto height = ::ChainActive().Height() + 1;

std::map<DCT_ID, std::pair<base_uint<128>, base_uint<128>> > interest;

Expand Down Expand Up @@ -1453,7 +1453,6 @@ UniValue getinterest(const JSONRPCRequest& request) {
for (auto it=interest.begin(); it != interest.end(); ++it)
{
auto tokenId = it->first;
auto interestRate = it->second;
auto totalInterest = it->second.first;
auto interestPerBlock = it->second.second;

Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/rpc_masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ UniValue getmasternodeblocks(const JSONRPCRequest& request) {
depth = std::min(depth, currentHeight);
auto startBlock = currentHeight - depth;

auto masternodeBlocks = [&](const uint256& masternodeID, uint32_t blockHeight) {
auto masternodeBlocks = [&](const uint256& masternodeID, int blockHeight) {
if (masternodeID != mn_id) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/masternodes/rpc_oracles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ UniValue setoracledata(const JSONRPCRequest &request) {
}

bool diffInHour(int64_t time1, int64_t time2) {
constexpr const uint64_t SECONDS_PER_HOUR = 3600u;
constexpr const int64_t SECONDS_PER_HOUR = 3600u;
return std::abs(time1 - time2) < SECONDS_PER_HOUR;
}

Expand Down Expand Up @@ -846,7 +846,7 @@ ResVal<CAmount> GetAggregatePrice(CCustomCSView& view, const std::string& token,
return true;
});

static const auto minimumLiveOracles = Params().NetworkIDString() == CBaseChainParams::REGTEST ? 1 : 2;
static const uint64_t minimumLiveOracles = Params().NetworkIDString() == CBaseChainParams::REGTEST ? 1 : 2;

if (numLiveOracles < minimumLiveOracles) {
return Res::Err("no live oracles for specified request");
Expand All @@ -866,7 +866,7 @@ namespace {
UniValue GetAllAggregatePrices(CCustomCSView& view, uint64_t lastBlockTime, const UniValue& paginationObj) {

size_t limit = 100;
int start = 0;
uint32_t start = 0;
bool including_start = true;
if (!paginationObj.empty()){
if (!paginationObj["limit"].isNull()) {
Expand Down
4 changes: 2 additions & 2 deletions src/masternodes/rpc_vault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace {
return "inLiquidation";
case VaultState::MayLiquidate:
return "mayLiquidate";
case VaultState::Unknown:
default:
return "unknown";
}
}
Expand Down Expand Up @@ -1220,7 +1220,7 @@ UniValue stateToJSON(VaultStateKey const & key, VaultStateValue const & value) {
snapshot.pushKV("state", !value.auctionBatches.empty() ? "inLiquidation" : "active");
snapshot.pushKV("collateralAmounts", AmountsToJSON(value.collaterals));
snapshot.pushKV("collateralValue", ValueFromUint(value.collateralsValues.totalCollaterals));
snapshot.pushKV("collateralRatio", value.ratio != -1 ? static_cast<int>(value.ratio) : static_cast<int>(value.collateralsValues.ratio()));
snapshot.pushKV("collateralRatio", static_cast<int>(value.ratio != static_cast<uint32_t>(-1) ? value.ratio :value.collateralsValues.ratio()));
if (!value.auctionBatches.empty()) {
snapshot.pushKV("batches", BatchToJSON(value.auctionBatches));
}
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2655,7 +2655,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
// possible optimization: stops when first quorum reached (irl, no need to walk deeper)
auto topAnchor = panchors->GetActiveAnchor();
// limit requested by the top anchor, if any
if (topAnchor && topAnchor->anchor.height > pLowRequested->nHeight && topAnchor->anchor.height <= (uint64_t) ::ChainActive().Height()) {
if (topAnchor && topAnchor->anchor.height > static_cast<THeight>(pLowRequested->nHeight) && topAnchor->anchor.height <= (uint64_t) ::ChainActive().Height()) {
pLowRequested = ::ChainActive()[topAnchor->anchor.height];
assert(pLowRequested);
}
Expand Down
6 changes: 3 additions & 3 deletions src/pos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ bool ContextualCheckProofOfStake(const CBlockHeader& blockHeader, const Consensu
}
creationHeight = int64_t(nodePtr->creationHeight);

if (height >= static_cast<uint64_t>(params.EunosPayaHeight)) {
if (height >= params.EunosPayaHeight) {
timelock = mnView->GetTimelock(masternodeID, *nodePtr, height);
}

// Check against EunosPayaHeight here for regtest, does not hurt other networks.
// Redundant checks, but intentionally kept for easier fork accounting.
if (height >= static_cast<uint64_t>(params.DakotaCrescentHeight) || height >= static_cast<uint64_t>(params.EunosPayaHeight)) {
const auto usedHeight = height <= static_cast<uint64_t>(params.EunosHeight) ? creationHeight : height;
if (height >= params.DakotaCrescentHeight || height >= params.EunosPayaHeight) {
const auto usedHeight = height <= params.EunosHeight ? creationHeight : height;

// Get block times
subNodesBlockTime = mnView->GetBlockTimes(nodePtr->operatorAuthAddress, usedHeight, creationHeight, timelock);
Expand Down
2 changes: 1 addition & 1 deletion src/spv/spv_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ UniValue spv_listanchors(const JSONRPCRequest& request)
return true; // continue
if ((minBtcHeight >= 0 && (int)rec.btcHeight < minBtcHeight) ||
(maxConfs >= 0 && confs > maxConfs) ||
(startBtcHeight >= 0 && static_cast<THeight>(rec.btcHeight) < startBtcHeight))
(startBtcHeight >= 0 && rec.btcHeight < static_cast<THeight>(startBtcHeight)))
return false; // break

UniValue anchor(UniValue::VOBJ);
Expand Down
4 changes: 2 additions & 2 deletions src/test/anchor_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(Test_AnchorFinalMsgCount)
CAnchorConfirmDataPlus confirmPlus{confirm};
CAnchorFinalizationMessagePlus finalMsg{confirmPlus};

for (int i{0}; i < 4 && i < signers.size(); ++i) {
for (size_t i{0}; i < 4 && i < signers.size(); ++i) {
CAnchorConfirmMessage confirmMsg{confirmPlus};
signers[i < 3 ? i : i - 1].SignCompact(confirmMsg.GetSignHash(), confirmMsg.signature);
finalMsg.sigs.push_back(confirmMsg.signature);
Expand All @@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(Test_AnchorMsgCount)
CAnchorData data{blockHash, 0, blockHash, CAnchorData::CTeam{}};
CAnchor anchor{data};

for (int i{0}; i < 4 && i < signers.size(); ++i) {
for (size_t i{0}; i < 4 && i < signers.size(); ++i) {
CAnchorAuthMessage authMsg{data};
authMsg.SignWithKey(signers[i < 3 ? i : i - 1]);
anchor.sigs.push_back(authMsg.GetSignature());
Expand Down
2 changes: 1 addition & 1 deletion src/test/liquidity_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ BOOST_AUTO_TEST_CASE(owner_rewards)
};
mnview.CalculatePoolRewards(idPool, onLiquidity, 1, 10,
[&](RewardType type, CTokenAmount amount, uint32_t height) {
if (height >= Params().GetConsensus().BayfrontGardensHeight) {
if (height >= static_cast<uint32_t>(Params().GetConsensus().BayfrontGardensHeight)) {
if (type == RewardType::Pool) {
for (const auto& reward : pool.rewards.balances) {
auto providerReward = static_cast<CAmount>((arith_uint256(reward.second) * arith_uint256(onLiquidity()) / arith_uint256(pool.totalLiquidity)).GetLow64());
Expand Down
Loading