Merge bitcoin/bitcoin#25705: tidy: enable readability-redundant-string-init

49168df073 tidy: enable readability-redundant-string-init (fanquake)
4ddd746bf9 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 49168df073

Tree-SHA512: 69e72a434908c9166d407551657b310361ae2ef0170f8289cb1c2b8e96a4632be718c0d55cb12af03a3c3d621d9583eced88e5e9d924abb0a8b1a9b36c903d66
This commit is contained in:
MacroFake 2022-07-26 17:47:50 +02:00
commit 7f79746bf0
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
6 changed files with 7 additions and 5 deletions

View file

@ -5,6 +5,7 @@ misc-unused-using-decls,
modernize-use-default-member-init,
modernize-use-nullptr,
readability-redundant-declaration,
readability-redundant-string-init,
'
WarningsAsErrors: '
bugprone-argument-comment,
@ -12,4 +13,5 @@ misc-unused-using-decls,
modernize-use-default-member-init,
modernize-use-nullptr,
readability-redundant-declaration,
readability-redundant-string-init,
'

View file

@ -148,7 +148,7 @@ bool GCSFilter::MatchAny(const ElementSet& elements) const
const std::string& BlockFilterTypeName(BlockFilterType filter_type)
{
static std::string unknown_retval = "";
static std::string unknown_retval;
auto it = g_filter_types.find(filter_type);
return it != g_filter_types.end() ? it->second : unknown_retval;
}

View file

@ -49,7 +49,7 @@ bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalS
if (signer.m_fingerprint.compare(fingerprintStr) == 0) duplicate = true;
}
if (duplicate) break;
std::string name = "";
std::string name;
const UniValue& model_field = find_value(signer, "model");
if (model_field.isStr() && model_field.getValStr() != "") {
name += model_field.getValStr();

View file

@ -740,7 +740,7 @@ std::string ArgsManager::GetHelpMessage() const
{
const bool show_debug = GetBoolArg("-help-debug", false);
std::string usage = "";
std::string usage;
LOCK(cs_args);
for (const auto& arg_map : m_available_args) {
switch(arg_map.first) {

View file

@ -140,7 +140,7 @@ RPCHelpMan importprivkey()
EnsureWalletIsUnlocked(*pwallet);
std::string strSecret = request.params[0].get_str();
std::string strLabel = "";
std::string strLabel;
if (!request.params[1].isNull())
strLabel = request.params[1].get_str();

View file

@ -241,7 +241,7 @@ static RPCHelpMan loadwallet()
static RPCHelpMan setwalletflag()
{
std::string flags = "";
std::string flags;
for (auto& it : WALLET_FLAG_MAP)
if (it.second & MUTABLE_WALLET_FLAGS)
flags += (flags == "" ? "" : ", ") + it.first;