Skip to content

Commit 550e6bd

Browse files
committed
Merge bitcoin/bitcoin#26935: refactor: Fix clang-tidy readability-const-return-type violations
fa451d4 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: utACK fa451d4 hebasto: ACK fa451d4. Tree-SHA512: 144a85612f00ec43f7ea1fdaa11901ca981a9f0465a8849745712d741b201b9c3307118172ee0b8efd12bebf25bc6f32a6e2c908495e371f9ada0a917994f44e
2 parents 8fc3bcf + fa451d4 commit 550e6bd

25 files changed

+54
-52
lines changed

src/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ performance-for-range-copy,
99
performance-move-const-arg,
1010
performance-no-automatic-move,
1111
performance-unnecessary-copy-initialization,
12+
readability-const-return-type,
1213
readability-redundant-declaration,
1314
readability-redundant-string-init,
1415
'

src/arith_uint256.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ class base_uint
5858

5959
explicit base_uint(const std::string& str);
6060

61-
const base_uint operator~() const
61+
base_uint operator~() const
6262
{
6363
base_uint ret;
6464
for (int i = 0; i < WIDTH; i++)
6565
ret.pn[i] = ~pn[i];
6666
return ret;
6767
}
6868

69-
const base_uint operator-() const
69+
base_uint operator-() const
7070
{
7171
base_uint ret;
7272
for (int i = 0; i < WIDTH; i++)
@@ -171,7 +171,7 @@ class base_uint
171171
return *this;
172172
}
173173

174-
const base_uint operator++(int)
174+
base_uint operator++(int)
175175
{
176176
// postfix operator
177177
const base_uint ret = *this;
@@ -188,7 +188,7 @@ class base_uint
188188
return *this;
189189
}
190190

191-
const base_uint operator--(int)
191+
base_uint operator--(int)
192192
{
193193
// postfix operator
194194
const base_uint ret = *this;
@@ -199,16 +199,16 @@ class base_uint
199199
int CompareTo(const base_uint& b) const;
200200
bool EqualTo(uint64_t b) const;
201201

202-
friend inline const base_uint operator+(const base_uint& a, const base_uint& b) { return base_uint(a) += b; }
203-
friend inline const base_uint operator-(const base_uint& a, const base_uint& b) { return base_uint(a) -= b; }
204-
friend inline const base_uint operator*(const base_uint& a, const base_uint& b) { return base_uint(a) *= b; }
205-
friend inline const base_uint operator/(const base_uint& a, const base_uint& b) { return base_uint(a) /= b; }
206-
friend inline const base_uint operator|(const base_uint& a, const base_uint& b) { return base_uint(a) |= b; }
207-
friend inline const base_uint operator&(const base_uint& a, const base_uint& b) { return base_uint(a) &= b; }
208-
friend inline const base_uint operator^(const base_uint& a, const base_uint& b) { return base_uint(a) ^= b; }
209-
friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; }
210-
friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
211-
friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
202+
friend inline base_uint operator+(const base_uint& a, const base_uint& b) { return base_uint(a) += b; }
203+
friend inline base_uint operator-(const base_uint& a, const base_uint& b) { return base_uint(a) -= b; }
204+
friend inline base_uint operator*(const base_uint& a, const base_uint& b) { return base_uint(a) *= b; }
205+
friend inline base_uint operator/(const base_uint& a, const base_uint& b) { return base_uint(a) /= b; }
206+
friend inline base_uint operator|(const base_uint& a, const base_uint& b) { return base_uint(a) |= b; }
207+
friend inline base_uint operator&(const base_uint& a, const base_uint& b) { return base_uint(a) &= b; }
208+
friend inline base_uint operator^(const base_uint& a, const base_uint& b) { return base_uint(a) ^= b; }
209+
friend inline base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; }
210+
friend inline base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
211+
friend inline base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
212212
friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; }
213213
friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; }
214214
friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; }

src/bench/gcs_filter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <bench/bench.h>
66
#include <blockfilter.h>
77

8-
static const GCSFilter::ElementSet GenerateGCSTestElements()
8+
static GCSFilter::ElementSet GenerateGCSTestElements()
99
{
1010
GCSFilter::ElementSet elements;
1111

src/bench/wallet_loading.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using wallet::WALLET_FLAG_DESCRIPTORS;
2424
using wallet::WalletContext;
2525
using wallet::WalletDatabase;
2626

27-
static const std::shared_ptr<CWallet> BenchLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context, DatabaseOptions& options)
27+
static std::shared_ptr<CWallet> BenchLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context, DatabaseOptions& options)
2828
{
2929
bilingual_str error;
3030
std::vector<bilingual_str> warnings;

src/external_signer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
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) {}
1818

19-
const std::string ExternalSigner::NetworkArg() const
19+
std::string ExternalSigner::NetworkArg() const
2020
{
2121
return " --chain " + m_chain;
2222
}

src/external_signer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ExternalSigner
2424
//! Bitcoin mainnet, testnet, etc
2525
std::string m_chain;
2626

27-
const std::string NetworkArg() const;
27+
std::string NetworkArg() const;
2828

2929
public:
3030
//! @param[in] command the command which handles interaction with the external signer

src/qt/optionsmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1";
3333

34-
static const QString GetDefaultProxyAddress();
34+
static QString GetDefaultProxyAddress();
3535

3636
/** Map GUI option ID to node setting name. */
3737
static const char* SettingName(OptionsModel::OptionID option)
@@ -308,7 +308,7 @@ static std::string ProxyString(bool is_set, QString ip, QString port)
308308
return is_set ? QString(ip + ":" + port).toStdString() : "";
309309
}
310310

311-
static const QString GetDefaultProxyAddress()
311+
static QString GetDefaultProxyAddress()
312312
{
313313
return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT);
314314
}

src/script/descriptor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,17 +1833,17 @@ DescriptorCache DescriptorCache::MergeAndDiff(const DescriptorCache& other)
18331833
return diff;
18341834
}
18351835

1836-
const ExtPubKeyMap DescriptorCache::GetCachedParentExtPubKeys() const
1836+
ExtPubKeyMap DescriptorCache::GetCachedParentExtPubKeys() const
18371837
{
18381838
return m_parent_xpubs;
18391839
}
18401840

1841-
const std::unordered_map<uint32_t, ExtPubKeyMap> DescriptorCache::GetCachedDerivedExtPubKeys() const
1841+
std::unordered_map<uint32_t, ExtPubKeyMap> DescriptorCache::GetCachedDerivedExtPubKeys() const
18421842
{
18431843
return m_derived_xpubs;
18441844
}
18451845

1846-
const ExtPubKeyMap DescriptorCache::GetCachedLastHardenedExtPubKeys() const
1846+
ExtPubKeyMap DescriptorCache::GetCachedLastHardenedExtPubKeys() const
18471847
{
18481848
return m_last_hardened_xpubs;
18491849
}

src/script/descriptor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ class DescriptorCache {
6666
bool GetCachedLastHardenedExtPubKey(uint32_t key_exp_pos, CExtPubKey& xpub) const;
6767

6868
/** Retrieve all cached parent xpubs */
69-
const ExtPubKeyMap GetCachedParentExtPubKeys() const;
69+
ExtPubKeyMap GetCachedParentExtPubKeys() const;
7070
/** Retrieve all cached derived xpubs */
71-
const std::unordered_map<uint32_t, ExtPubKeyMap> GetCachedDerivedExtPubKeys() const;
71+
std::unordered_map<uint32_t, ExtPubKeyMap> GetCachedDerivedExtPubKeys() const;
7272
/** Retrieve all cached last hardened xpubs */
73-
const ExtPubKeyMap GetCachedLastHardenedExtPubKeys() const;
73+
ExtPubKeyMap GetCachedLastHardenedExtPubKeys() const;
7474

7575
/** Combine another DescriptorCache into this one.
7676
* Returns a cache containing the items from the other cache unknown to current cache

src/test/fuzz/miniscript.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct ScriptParserContext {
104104
return key.data;
105105
}
106106

107-
const std::vector<unsigned char> ToPKHBytes(const Key& key) const
107+
std::vector<unsigned char> ToPKHBytes(const Key& key) const
108108
{
109109
if (key.is_hash) return key.data;
110110
const auto h = Hash160(key.data);

0 commit comments

Comments
 (0)