From 34864c52542950055c006e2855c2c6233816817b Mon Sep 17 00:00:00 2001 From: root Date: Tue, 28 Apr 2026 07:34:45 +0000 Subject: [PATCH] Fix build warning issues --- src/hash.h | 2 +- src/invalid.cpp | 7 +++---- src/libzerocoin/SerialNumberSignatureOfKnowledge.cpp | 2 +- src/masternodeconfig.cpp | 2 +- src/rpc/blockchain.cpp | 2 +- src/rpc/mining.cpp | 4 ++-- src/rpc/rawtransaction.cpp | 5 ++--- src/rpc/server.cpp | 4 ++-- src/wallet/rpcwallet.cpp | 4 ++-- src/wallet/walletdb.cpp | 2 +- src/zagr/accumulatorcheckpoints.cpp | 5 ++--- 11 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/hash.h b/src/hash.h index 2295a79c..275abe3b 100644 --- a/src/hash.h +++ b/src/hash.h @@ -153,7 +153,7 @@ inline std::string Hash(std::string input) unsigned char hash[CSHA256::OUTPUT_SIZE]; CSHA256().Write((const unsigned char*)input.data(), input.size()).Finalize(hash); stringstream ss; - for (int i = 0; i < CSHA256::OUTPUT_SIZE; i++) { + for (size_t i = 0; i < CSHA256::OUTPUT_SIZE; i++) { ss << hex << setw(2) << setfill('0') << (int)hash[i]; } return ss.str(); diff --git a/src/invalid.cpp b/src/invalid.cpp index 0a9ea861..3e685df7 100644 --- a/src/invalid.cpp +++ b/src/invalid.cpp @@ -33,7 +33,7 @@ namespace invalid_out const UniValue &val = v[idx]; const UniValue &o = val.get_obj(); - const UniValue &vTxid = find_value(o, "txid"); + const UniValue vTxid = find_value(o, "txid"); if (!vTxid.isStr()) return false; @@ -41,7 +41,7 @@ namespace invalid_out if (txid == 0) return false; - const UniValue &vN = find_value(o, "n"); + const UniValue vN = find_value(o, "n"); if (!vN.isNum()) return false; @@ -63,7 +63,7 @@ namespace invalid_out const UniValue &val = v[idx]; const UniValue &o = val.get_obj(); - const UniValue &vSerial = find_value(o, "s"); + const UniValue vSerial = find_value(o, "s"); if (!vSerial.isStr()) return false; @@ -87,4 +87,3 @@ namespace invalid_out return static_cast(setInvalidSerials.count(bnSerial)); } } - diff --git a/src/libzerocoin/SerialNumberSignatureOfKnowledge.cpp b/src/libzerocoin/SerialNumberSignatureOfKnowledge.cpp index e635827a..e2791a03 100644 --- a/src/libzerocoin/SerialNumberSignatureOfKnowledge.cpp +++ b/src/libzerocoin/SerialNumberSignatureOfKnowledge.cpp @@ -170,7 +170,7 @@ bool SerialNumberSignatureOfKnowledge::Verify(const CBigNum& coinSerialNumber, c hasher << tprime[i]; } return hasher.GetHash() == hash; - }catch (std::range_error e){ + }catch (const std::range_error& e){ return error("SoK Verify() :: sprime invalid range."); } } diff --git a/src/masternodeconfig.cpp b/src/masternodeconfig.cpp index 1858a5b0..dbacff2e 100644 --- a/src/masternodeconfig.cpp +++ b/src/masternodeconfig.cpp @@ -96,7 +96,7 @@ bool CMasternodeConfig::CMasternodeEntry::castOutputIndex(int &n) { try { n = std::stoi(outputIndex); - } catch (const std::exception e) { + } catch (const std::exception& e) { LogPrintf("%s: %s on getOutputIndex\n", __func__, e.what()); return false; } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 3ee24fa4..90693279 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -434,7 +434,7 @@ UniValue mempoolToJSON(bool fVerbose = false) if (fVerbose) { LOCK(mempool.cs); UniValue o(UniValue::VOBJ); - for (const PAIRTYPE(uint256, CTxMemPoolEntry) & entry : mempool.mapTx) { + for (const auto& entry : mempool.mapTx) { const uint256& hash = entry.first; const CTxMemPoolEntry& e = entry.second; UniValue info(UniValue::VOBJ); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index a96a1b14..17d54445 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -418,7 +418,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) UniValue lpval = NullUniValue; if (params.size() > 0) { const UniValue& oparam = params[0].get_obj(); - const UniValue& modeval = find_value(oparam, "mode"); + const UniValue modeval = find_value(oparam, "mode"); if (modeval.isStr()) strMode = modeval.get_str(); else if (modeval.isNull()) { @@ -428,7 +428,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) lpval = find_value(oparam, "longpollid"); if (strMode == "proposal") { - const UniValue& dataval = find_value(oparam, "data"); + const UniValue dataval = find_value(oparam, "data"); if (!dataval.isStr()) throw JSONRPCError(RPC_TYPE_ERROR, "Missing data String key for proposal"); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 400e376b..67d66df4 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -383,7 +383,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) uint256 txid = ParseHashO(o, "txid"); - const UniValue& vout_v = find_value(o, "vout"); + const UniValue vout_v = find_value(o, "vout"); if (!vout_v.isNum()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key"); int nOutput = vout_v.get_int(); @@ -393,7 +393,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) uint32_t nSequence = (rawTx.nLockTime ? std::numeric_limits::max() - 1 : std::numeric_limits::max()); // set the sequence number if passed in the parameters object - const UniValue& sequenceObj = find_value(o, "sequence"); + const UniValue sequenceObj = find_value(o, "sequence"); if (sequenceObj.isNum()) { int64_t seqNr64 = sequenceObj.get_int64(); if (seqNr64 < 0 || seqNr64 > std::numeric_limits::max()) @@ -1057,4 +1057,3 @@ UniValue createrawzerocoinpublicspend(const UniValue& params, bool fHelp) return EncodeHexTx(rawTx); } #endif - diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index ddcdad01..703901e6 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -93,8 +93,8 @@ void RPCTypeCheckObj(const UniValue& o, const map& typesExpected, bool fAllowNull) { - for (const PAIRTYPE(string, UniValue::VType)& t : typesExpected) { - const UniValue& v = find_value(o, t.first); + for (const auto& t : typesExpected) { + const UniValue v = find_value(o, t.first); if (!fAllowNull && v.isNull()) throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first)); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 89aaedce..257d95ad 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3365,7 +3365,7 @@ UniValue importzerocoins(const UniValue& params, bool fHelp) const UniValue &val = arrMints[idx]; const UniValue &o = val.get_obj(); - const UniValue& vDenom = find_value(o, "d"); + const UniValue vDenom = find_value(o, "d"); if (!vDenom.isNum()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing d key"); int d = vDenom.get_int(); @@ -3389,7 +3389,7 @@ UniValue importzerocoins(const UniValue& params, bool fHelp) //Assume coin is version 1 unless it has the version actually set uint8_t nVersion = 1; - const UniValue& vVersion = find_value(o, "v"); + const UniValue vVersion = find_value(o, "v"); if (vVersion.isNum()) nVersion = static_cast(vVersion.get_int()); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 0ae1e4f3..fccf8821 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1077,7 +1077,7 @@ bool AttemptBackupWallet(const CWallet& wallet, const filesystem::path& pathSrc, return false; } #if BOOST_VERSION >= 105800 /* BOOST_LIB_VERSION 1_58 */ - filesystem::copy_file(pathSrc.c_str(), pathDest, filesystem::copy_options::overwrite_existing); + filesystem::copy_file(pathSrc.c_str(), pathDest, filesystem::copy_option::overwrite_if_exists); #else std::ifstream src(pathSrc.c_str(), std::ios::binary | std::ios::in); std::ofstream dst(pathDest.c_str(), std::ios::binary | std::ios::out | std::ios::trunc); diff --git a/src/zagr/accumulatorcheckpoints.cpp b/src/zagr/accumulatorcheckpoints.cpp index 3602e69e..aeb1b3a0 100644 --- a/src/zagr/accumulatorcheckpoints.cpp +++ b/src/zagr/accumulatorcheckpoints.cpp @@ -39,7 +39,7 @@ namespace AccumulatorCheckpoints const UniValue &val = v[idx]; const UniValue &o = val.get_obj(); - const UniValue &vHeight = find_value(o, "height"); + const UniValue vHeight = find_value(o, "height"); if (!vHeight.isNum()) return false; @@ -49,7 +49,7 @@ namespace AccumulatorCheckpoints Checkpoint checkpoint; for (auto denom : libzerocoin::zerocoinDenomList) { - const UniValue& vDenomValue = find_value(o, std::to_string(denom)); + const UniValue vDenomValue = find_value(o, std::to_string(denom)); if (!vDenomValue.isStr()) { return false; } @@ -82,4 +82,3 @@ namespace AccumulatorCheckpoints return Checkpoint(); } } -