Skip to content

Commit 7f79746

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25705: tidy: enable readability-redundant-string-init
49168df tidy: enable readability-redundant-string-init (fanquake) 4ddd746 refactor: remove unnecessary string initializations (fanquake) Pull request description: Remove unnecessary `std::string` = "" initializations. Enable `readability-redundant-string-init`. See: https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/readability-redundant-string-init.html ACKs for top commit: shaavan: ACK 49168df Tree-SHA512: 69e72a434908c9166d407551657b310361ae2ef0170f8289cb1c2b8e96a4632be718c0d55cb12af03a3c3d621d9583eced88e5e9d924abb0a8b1a9b36c903d66
2 parents 5671217 + 49168df commit 7f79746

File tree

6 files changed

+7
-5
lines changed

6 files changed

+7
-5
lines changed

src/.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ misc-unused-using-decls,
55
modernize-use-default-member-init,
66
modernize-use-nullptr,
77
readability-redundant-declaration,
8+
readability-redundant-string-init,
89
'
910
WarningsAsErrors: '
1011
bugprone-argument-comment,
1112
misc-unused-using-decls,
1213
modernize-use-default-member-init,
1314
modernize-use-nullptr,
1415
readability-redundant-declaration,
16+
readability-redundant-string-init,
1517
'

src/blockfilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ bool GCSFilter::MatchAny(const ElementSet& elements) const
148148

149149
const std::string& BlockFilterTypeName(BlockFilterType filter_type)
150150
{
151-
static std::string unknown_retval = "";
151+
static std::string unknown_retval;
152152
auto it = g_filter_types.find(filter_type);
153153
return it != g_filter_types.end() ? it->second : unknown_retval;
154154
}

src/external_signer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalS
4949
if (signer.m_fingerprint.compare(fingerprintStr) == 0) duplicate = true;
5050
}
5151
if (duplicate) break;
52-
std::string name = "";
52+
std::string name;
5353
const UniValue& model_field = find_value(signer, "model");
5454
if (model_field.isStr() && model_field.getValStr() != "") {
5555
name += model_field.getValStr();

src/util/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ std::string ArgsManager::GetHelpMessage() const
740740
{
741741
const bool show_debug = GetBoolArg("-help-debug", false);
742742

743-
std::string usage = "";
743+
std::string usage;
744744
LOCK(cs_args);
745745
for (const auto& arg_map : m_available_args) {
746746
switch(arg_map.first) {

src/wallet/rpc/backup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ RPCHelpMan importprivkey()
140140
EnsureWalletIsUnlocked(*pwallet);
141141

142142
std::string strSecret = request.params[0].get_str();
143-
std::string strLabel = "";
143+
std::string strLabel;
144144
if (!request.params[1].isNull())
145145
strLabel = request.params[1].get_str();
146146

src/wallet/rpc/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static RPCHelpMan loadwallet()
241241

242242
static RPCHelpMan setwalletflag()
243243
{
244-
std::string flags = "";
244+
std::string flags;
245245
for (auto& it : WALLET_FLAG_MAP)
246246
if (it.second & MUTABLE_WALLET_FLAGS)
247247
flags += (flags == "" ? "" : ", ") + it.first;

0 commit comments

Comments
 (0)