mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
Merge bitcoin/bitcoin#26935: refactor: Fix clang-tidy readability-const-return-type violations
fa451d4b60
Fix clang-tidy readability-const-return-type violations (MarcoFalke) Pull request description: This comes up during review, so instead of wasting review cycles on this, just enforce it via CI ACKs for top commit: stickies-v: utACKfa451d4b6
hebasto: ACKfa451d4b60
. Tree-SHA512: 144a85612f00ec43f7ea1fdaa11901ca981a9f0465a8849745712d741b201b9c3307118172ee0b8efd12bebf25bc6f32a6e2c908495e371f9ada0a917994f44e
This commit is contained in:
commit
550e6bd227
25 changed files with 54 additions and 52 deletions
|
@ -9,6 +9,7 @@ performance-for-range-copy,
|
|||
performance-move-const-arg,
|
||||
performance-no-automatic-move,
|
||||
performance-unnecessary-copy-initialization,
|
||||
readability-const-return-type,
|
||||
readability-redundant-declaration,
|
||||
readability-redundant-string-init,
|
||||
'
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
explicit base_uint(const std::string& str);
|
||||
|
||||
const base_uint operator~() const
|
||||
base_uint operator~() const
|
||||
{
|
||||
base_uint ret;
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
const base_uint operator-() const
|
||||
base_uint operator-() const
|
||||
{
|
||||
base_uint ret;
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
|
@ -171,7 +171,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
const base_uint operator++(int)
|
||||
base_uint operator++(int)
|
||||
{
|
||||
// postfix operator
|
||||
const base_uint ret = *this;
|
||||
|
@ -188,7 +188,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
const base_uint operator--(int)
|
||||
base_uint operator--(int)
|
||||
{
|
||||
// postfix operator
|
||||
const base_uint ret = *this;
|
||||
|
@ -199,16 +199,16 @@ public:
|
|||
int CompareTo(const base_uint& b) const;
|
||||
bool EqualTo(uint64_t b) const;
|
||||
|
||||
friend inline const base_uint operator+(const base_uint& a, const base_uint& b) { return base_uint(a) += b; }
|
||||
friend inline const base_uint operator-(const base_uint& a, const base_uint& b) { return base_uint(a) -= b; }
|
||||
friend inline const base_uint operator*(const base_uint& a, const base_uint& b) { return base_uint(a) *= b; }
|
||||
friend inline const base_uint operator/(const base_uint& a, const base_uint& b) { return base_uint(a) /= b; }
|
||||
friend inline const base_uint operator|(const base_uint& a, const base_uint& b) { return base_uint(a) |= b; }
|
||||
friend inline const base_uint operator&(const base_uint& a, const base_uint& b) { return base_uint(a) &= b; }
|
||||
friend inline const base_uint operator^(const base_uint& a, const base_uint& b) { return base_uint(a) ^= b; }
|
||||
friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; }
|
||||
friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
|
||||
friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
|
||||
friend inline base_uint operator+(const base_uint& a, const base_uint& b) { return base_uint(a) += b; }
|
||||
friend inline base_uint operator-(const base_uint& a, const base_uint& b) { return base_uint(a) -= b; }
|
||||
friend inline base_uint operator*(const base_uint& a, const base_uint& b) { return base_uint(a) *= b; }
|
||||
friend inline base_uint operator/(const base_uint& a, const base_uint& b) { return base_uint(a) /= b; }
|
||||
friend inline base_uint operator|(const base_uint& a, const base_uint& b) { return base_uint(a) |= b; }
|
||||
friend inline base_uint operator&(const base_uint& a, const base_uint& b) { return base_uint(a) &= b; }
|
||||
friend inline base_uint operator^(const base_uint& a, const base_uint& b) { return base_uint(a) ^= b; }
|
||||
friend inline base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; }
|
||||
friend inline base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
|
||||
friend inline base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
|
||||
friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; }
|
||||
friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; }
|
||||
friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; }
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <bench/bench.h>
|
||||
#include <blockfilter.h>
|
||||
|
||||
static const GCSFilter::ElementSet GenerateGCSTestElements()
|
||||
static GCSFilter::ElementSet GenerateGCSTestElements()
|
||||
{
|
||||
GCSFilter::ElementSet elements;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ using wallet::WALLET_FLAG_DESCRIPTORS;
|
|||
using wallet::WalletContext;
|
||||
using wallet::WalletDatabase;
|
||||
|
||||
static const std::shared_ptr<CWallet> BenchLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context, DatabaseOptions& options)
|
||||
static std::shared_ptr<CWallet> BenchLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context, DatabaseOptions& options)
|
||||
{
|
||||
bilingual_str error;
|
||||
std::vector<bilingual_str> warnings;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
ExternalSigner::ExternalSigner(const std::string& command, const std::string chain, const std::string& fingerprint, const std::string name): m_command(command), m_chain(chain), m_fingerprint(fingerprint), m_name(name) {}
|
||||
|
||||
const std::string ExternalSigner::NetworkArg() const
|
||||
std::string ExternalSigner::NetworkArg() const
|
||||
{
|
||||
return " --chain " + m_chain;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ private:
|
|||
//! Bitcoin mainnet, testnet, etc
|
||||
std::string m_chain;
|
||||
|
||||
const std::string NetworkArg() const;
|
||||
std::string NetworkArg() const;
|
||||
|
||||
public:
|
||||
//! @param[in] command the command which handles interaction with the external signer
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1";
|
||||
|
||||
static const QString GetDefaultProxyAddress();
|
||||
static QString GetDefaultProxyAddress();
|
||||
|
||||
/** Map GUI option ID to node setting name. */
|
||||
static const char* SettingName(OptionsModel::OptionID option)
|
||||
|
@ -308,7 +308,7 @@ static std::string ProxyString(bool is_set, QString ip, QString port)
|
|||
return is_set ? QString(ip + ":" + port).toStdString() : "";
|
||||
}
|
||||
|
||||
static const QString GetDefaultProxyAddress()
|
||||
static QString GetDefaultProxyAddress()
|
||||
{
|
||||
return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT);
|
||||
}
|
||||
|
|
|
@ -1833,17 +1833,17 @@ DescriptorCache DescriptorCache::MergeAndDiff(const DescriptorCache& other)
|
|||
return diff;
|
||||
}
|
||||
|
||||
const ExtPubKeyMap DescriptorCache::GetCachedParentExtPubKeys() const
|
||||
ExtPubKeyMap DescriptorCache::GetCachedParentExtPubKeys() const
|
||||
{
|
||||
return m_parent_xpubs;
|
||||
}
|
||||
|
||||
const std::unordered_map<uint32_t, ExtPubKeyMap> DescriptorCache::GetCachedDerivedExtPubKeys() const
|
||||
std::unordered_map<uint32_t, ExtPubKeyMap> DescriptorCache::GetCachedDerivedExtPubKeys() const
|
||||
{
|
||||
return m_derived_xpubs;
|
||||
}
|
||||
|
||||
const ExtPubKeyMap DescriptorCache::GetCachedLastHardenedExtPubKeys() const
|
||||
ExtPubKeyMap DescriptorCache::GetCachedLastHardenedExtPubKeys() const
|
||||
{
|
||||
return m_last_hardened_xpubs;
|
||||
}
|
||||
|
|
|
@ -66,11 +66,11 @@ public:
|
|||
bool GetCachedLastHardenedExtPubKey(uint32_t key_exp_pos, CExtPubKey& xpub) const;
|
||||
|
||||
/** Retrieve all cached parent xpubs */
|
||||
const ExtPubKeyMap GetCachedParentExtPubKeys() const;
|
||||
ExtPubKeyMap GetCachedParentExtPubKeys() const;
|
||||
/** Retrieve all cached derived xpubs */
|
||||
const std::unordered_map<uint32_t, ExtPubKeyMap> GetCachedDerivedExtPubKeys() const;
|
||||
std::unordered_map<uint32_t, ExtPubKeyMap> GetCachedDerivedExtPubKeys() const;
|
||||
/** Retrieve all cached last hardened xpubs */
|
||||
const ExtPubKeyMap GetCachedLastHardenedExtPubKeys() const;
|
||||
ExtPubKeyMap GetCachedLastHardenedExtPubKeys() const;
|
||||
|
||||
/** Combine another DescriptorCache into this one.
|
||||
* Returns a cache containing the items from the other cache unknown to current cache
|
||||
|
|
|
@ -104,7 +104,7 @@ struct ScriptParserContext {
|
|||
return key.data;
|
||||
}
|
||||
|
||||
const std::vector<unsigned char> ToPKHBytes(const Key& key) const
|
||||
std::vector<unsigned char> ToPKHBytes(const Key& key) const
|
||||
{
|
||||
if (key.is_hash) return key.data;
|
||||
const auto h = Hash160(key.data);
|
||||
|
|
|
@ -47,7 +47,7 @@ size_t CallOneOf(FuzzedDataProvider& fuzzed_data_provider, Callables... callable
|
|||
template <typename Collection>
|
||||
auto& PickValue(FuzzedDataProvider& fuzzed_data_provider, Collection& col)
|
||||
{
|
||||
const auto sz = col.size();
|
||||
auto sz{col.size()};
|
||||
assert(sz >= 1);
|
||||
auto it = col.begin();
|
||||
std::advance(it, fuzzed_data_provider.ConsumeIntegralInRange<decltype(sz)>(0, sz - 1));
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
/* Define a virtual block time, one block per 10 minutes after Nov 14 2014, 0:55:36am */
|
||||
static int32_t TestTime(int nHeight) { return 1415926536 + 600 * nHeight; }
|
||||
|
||||
static const std::string StateName(ThresholdState state)
|
||||
static std::string StateName(ThresholdState state)
|
||||
{
|
||||
switch (state) {
|
||||
case ThresholdState::DEFINED: return "DEFINED";
|
||||
|
|
|
@ -1128,7 +1128,7 @@ void CTxMemPool::SetLoadTried(bool load_tried)
|
|||
}
|
||||
|
||||
|
||||
const std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept
|
||||
std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept
|
||||
{
|
||||
switch (r) {
|
||||
case MemPoolRemovalReason::EXPIRY: return "expiry";
|
||||
|
|
|
@ -237,7 +237,7 @@ enum class MemPoolRemovalReason {
|
|||
REPLACED, //!< Removed for replacement
|
||||
};
|
||||
|
||||
const std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
|
||||
std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
|
||||
|
||||
/**
|
||||
* CTxMemPool stores valid-according-to-the-current-best-chain transactions
|
||||
|
|
|
@ -49,7 +49,7 @@ std::string FeeModes(const std::string& delimiter)
|
|||
return Join(FeeModeMap(), delimiter, [&](const std::pair<std::string, FeeEstimateMode>& i) { return i.first; });
|
||||
}
|
||||
|
||||
const std::string InvalidEstimateModeErrorMessage()
|
||||
std::string InvalidEstimateModeErrorMessage()
|
||||
{
|
||||
return "Invalid estimate_mode parameter, must be one of: \"" + FeeModes("\", \"") + "\"";
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ enum class FeeReason;
|
|||
bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode);
|
||||
std::string StringForFeeReason(FeeReason reason);
|
||||
std::string FeeModes(const std::string& delimiter);
|
||||
const std::string InvalidEstimateModeErrorMessage();
|
||||
std::string InvalidEstimateModeErrorMessage();
|
||||
|
||||
#endif // BITCOIN_UTIL_FEES_H
|
||||
|
|
|
@ -242,7 +242,7 @@ static std::optional<util::SettingsValue> InterpretValue(const KeyInfo& key, con
|
|||
ArgsManager::ArgsManager() = default;
|
||||
ArgsManager::~ArgsManager() = default;
|
||||
|
||||
const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
|
||||
std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
|
||||
{
|
||||
std::set<std::string> unsuitables;
|
||||
|
||||
|
@ -262,7 +262,7 @@ const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
|
|||
return unsuitables;
|
||||
}
|
||||
|
||||
const std::list<SectionInfo> ArgsManager::GetUnrecognizedSections() const
|
||||
std::list<SectionInfo> ArgsManager::GetUnrecognizedSections() const
|
||||
{
|
||||
// Section names to be recognized in the config file.
|
||||
static const std::set<std::string> available_sections{
|
||||
|
|
|
@ -250,12 +250,12 @@ protected:
|
|||
* on the command line or in a network-specific section in the
|
||||
* config file.
|
||||
*/
|
||||
const std::set<std::string> GetUnsuitableSectionOnlyArgs() const;
|
||||
std::set<std::string> GetUnsuitableSectionOnlyArgs() const;
|
||||
|
||||
/**
|
||||
* Log warnings for unrecognized section names in the config file.
|
||||
*/
|
||||
const std::list<SectionInfo> GetUnrecognizedSections() const;
|
||||
std::list<SectionInfo> GetUnrecognizedSections() const;
|
||||
|
||||
struct Command {
|
||||
/** The command (if one has been registered with AddCommand), or empty */
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
const std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
|
||||
std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
|
||||
|
||||
/**
|
||||
* MainSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks.
|
||||
|
|
|
@ -397,7 +397,7 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM
|
|||
}
|
||||
|
||||
|
||||
static const std::vector<RPCResult> TransactionDescriptionString()
|
||||
static std::vector<RPCResult> TransactionDescriptionString()
|
||||
{
|
||||
return{{RPCResult::Type::NUM, "confirmations", "The number of confirmations for the transaction. Negative confirmations means the\n"
|
||||
"transaction conflicted that many blocks ago."},
|
||||
|
|
|
@ -1664,7 +1664,7 @@ std::set<CKeyID> LegacyScriptPubKeyMan::GetKeys() const
|
|||
return set_address;
|
||||
}
|
||||
|
||||
const std::unordered_set<CScript, SaltedSipHasher> LegacyScriptPubKeyMan::GetScriptPubKeys() const
|
||||
std::unordered_set<CScript, SaltedSipHasher> LegacyScriptPubKeyMan::GetScriptPubKeys() const
|
||||
{
|
||||
LOCK(cs_KeyStore);
|
||||
std::unordered_set<CScript, SaltedSipHasher> spks;
|
||||
|
@ -2650,17 +2650,17 @@ void DescriptorScriptPubKeyMan::WriteDescriptor()
|
|||
}
|
||||
}
|
||||
|
||||
const WalletDescriptor DescriptorScriptPubKeyMan::GetWalletDescriptor() const
|
||||
WalletDescriptor DescriptorScriptPubKeyMan::GetWalletDescriptor() const
|
||||
{
|
||||
return m_wallet_descriptor;
|
||||
}
|
||||
|
||||
const std::unordered_set<CScript, SaltedSipHasher> DescriptorScriptPubKeyMan::GetScriptPubKeys() const
|
||||
std::unordered_set<CScript, SaltedSipHasher> DescriptorScriptPubKeyMan::GetScriptPubKeys() const
|
||||
{
|
||||
return GetScriptPubKeys(0);
|
||||
}
|
||||
|
||||
const std::unordered_set<CScript, SaltedSipHasher> DescriptorScriptPubKeyMan::GetScriptPubKeys(int32_t minimum_index) const
|
||||
std::unordered_set<CScript, SaltedSipHasher> DescriptorScriptPubKeyMan::GetScriptPubKeys(int32_t minimum_index) const
|
||||
{
|
||||
LOCK(cs_desc_man);
|
||||
std::unordered_set<CScript, SaltedSipHasher> script_pub_keys;
|
||||
|
|
|
@ -36,7 +36,7 @@ class WalletStorage
|
|||
{
|
||||
public:
|
||||
virtual ~WalletStorage() = default;
|
||||
virtual const std::string GetDisplayName() const = 0;
|
||||
virtual std::string GetDisplayName() const = 0;
|
||||
virtual WalletDatabase& GetDatabase() const = 0;
|
||||
virtual bool IsWalletFlagSet(uint64_t) const = 0;
|
||||
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
|
||||
|
@ -243,7 +243,7 @@ public:
|
|||
virtual uint256 GetID() const { return uint256(); }
|
||||
|
||||
/** Returns a set of all the scriptPubKeys that this ScriptPubKeyMan watches */
|
||||
virtual const std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys() const { return {}; };
|
||||
virtual std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys() const { return {}; };
|
||||
|
||||
/** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */
|
||||
template<typename... Params>
|
||||
|
@ -512,7 +512,7 @@ public:
|
|||
const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
|
||||
|
||||
std::set<CKeyID> GetKeys() const override;
|
||||
const std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys() const override;
|
||||
std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys() const override;
|
||||
|
||||
/** Get the DescriptorScriptPubKeyMans (with private keys) that have the same scriptPubKeys as this LegacyScriptPubKeyMan.
|
||||
* Does not modify this ScriptPubKeyMan. */
|
||||
|
@ -641,9 +641,9 @@ public:
|
|||
void AddDescriptorKey(const CKey& key, const CPubKey &pubkey);
|
||||
void WriteDescriptor();
|
||||
|
||||
const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
|
||||
const std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys() const override;
|
||||
const std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys(int32_t minimum_index) const;
|
||||
WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
|
||||
std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys() const override;
|
||||
std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys(int32_t minimum_index) const;
|
||||
int32_t GetEndRange() const;
|
||||
|
||||
bool GetDescriptorString(std::string& out, const bool priv) const;
|
||||
|
|
|
@ -43,7 +43,7 @@ static_assert(WALLET_INCREMENTAL_RELAY_FEE >= DEFAULT_INCREMENTAL_RELAY_FEE, "wa
|
|||
|
||||
BOOST_FIXTURE_TEST_SUITE(wallet_tests, WalletTestingSetup)
|
||||
|
||||
static const std::shared_ptr<CWallet> TestLoadWallet(WalletContext& context)
|
||||
static std::shared_ptr<CWallet> TestLoadWallet(WalletContext& context)
|
||||
{
|
||||
DatabaseOptions options;
|
||||
options.create_flags = WALLET_FLAG_DESCRIPTORS;
|
||||
|
|
|
@ -821,7 +821,8 @@ public:
|
|||
bool IsLegacy() const;
|
||||
|
||||
/** Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet has no name */
|
||||
const std::string GetDisplayName() const override {
|
||||
std::string GetDisplayName() const override
|
||||
{
|
||||
std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName();
|
||||
return strprintf("[%s]", wallet_name);
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ static void WalletCreate(CWallet* wallet_instance, uint64_t wallet_creation_flag
|
|||
wallet_instance->TopUpKeyPool();
|
||||
}
|
||||
|
||||
static const std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::path& path, const ArgsManager& args, DatabaseOptions options)
|
||||
static std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::path& path, const ArgsManager& args, DatabaseOptions options)
|
||||
{
|
||||
DatabaseStatus status;
|
||||
bilingual_str error;
|
||||
|
|
Loading…
Reference in a new issue