From c17de5429e52b5ef8443e2647de3f01b43dfae4b Mon Sep 17 00:00:00 2001 From: Benjamin Woosley Date: Sat, 24 Feb 2024 15:45:19 -0300 Subject: [PATCH 1/4] refactor: Don't redundantly define error in common/init.cpp common/init.cpp:73:31: error: declaration shadows a local variable [-Werror,-Wshadow] const std::string error = strprintf( ^ common/init.cpp:37:21: note: previous declaration is here std::string error; ^ --- src/common/init.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/init.cpp b/src/common/init.cpp index 5a70440468..762d85e1bc 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -34,9 +34,9 @@ std::optional InitConfig(ArgsManager& args, SettingsAbortFn setting const fs::path orig_datadir_path{args.GetDataDirBase()}; const fs::path orig_config_path{AbsPathForConfigVal(args, args.GetPathArg("-conf", BITCOIN_CONF_FILENAME), /*net_specific=*/false)}; - std::string error; - if (!args.ReadConfigFiles(error, true)) { - return ConfigError{ConfigStatus::FAILED, strprintf(_("Error reading configuration file: %s"), error)}; + std::string config_error; + if (!args.ReadConfigFiles(config_error, true)) { + return ConfigError{ConfigStatus::FAILED, strprintf(_("Error reading configuration file: %s"), config_error)}; } // Check for chain settings (Params() calls are only valid after this clause) From f953bf4d99ee2cf900541b68e504e1fcbd95f20e Mon Sep 17 00:00:00 2001 From: Benjamin Woosley Date: Sat, 24 Feb 2024 17:15:31 -0300 Subject: [PATCH 2/4] refactor: Don't redundantly define porphanTx in net_processing.cpp net_processing.cpp:3042:28: error: declaration shadows a local variable [-Werror,-Wshadow] while (CTransactionRef porphanTx = m_orphanage.GetTxToReconsider(peer.m_id)) { ^ net_processing.cpp:3040:21: note: previous declaration is here CTransactionRef porphanTx = nullptr; ^ --- src/net_processing.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index def758b915..2aab619620 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3069,8 +3069,6 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer) AssertLockHeld(g_msgproc_mutex); LOCK2(::cs_main, m_tx_download_mutex); - CTransactionRef porphanTx = nullptr; - while (CTransactionRef porphanTx = m_txdownloadman.GetTxToReconsider(peer.m_id)) { const MempoolAcceptResult result = m_chainman.ProcessTransaction(porphanTx); const TxValidationState& state = result.m_state; From b267c98c6c695b043b87639e2fb500dc999722dc Mon Sep 17 00:00:00 2001 From: Benjamin Woosley Date: Sat, 24 Feb 2024 17:17:41 -0300 Subject: [PATCH 3/4] refactor: Don't redundantly define TxItems in wallet/wallet.cpp wallet/wallet.cpp:901:48: error: declaration shadows a typedef in 'wallet::CWallet' [-Werror,-Wshadow] typedef std::multimap TxItems; ^ ./wallet/wallet.h:483:48: note: previous declaration is here typedef std::multimap TxItems; ^ --- src/wallet/wallet.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index dd9dfcd516..3a9ffc0b73 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -919,7 +919,6 @@ DBErrors CWallet::ReorderTransactions() // Probably a bad idea to change the output of this // First: get all CWalletTx into a sorted-by-time multimap. - typedef std::multimap TxItems; TxItems txByTime; for (auto& entry : mapWallet) From 6d300e84d454ddd4adfb54f20d267f3f7579ab8b Mon Sep 17 00:00:00 2001 From: Benjamin Woosley Date: Mon, 26 Feb 2024 18:03:41 -0300 Subject: [PATCH 4/4] test: Don't redundantly define msg in key_tests test/key_tests.cpp:184:21: error: declaration shadows a local variable [-Werror,-Wshadow] std::string msg = "A message to be signed" + ToString(i); ^ test/key_tests.cpp:161:17: note: previous declaration is here std::string msg = "A message to be signed"; ^ --- src/test/key_tests.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index 90e04bed87..36d189e471 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -166,8 +166,7 @@ BOOST_AUTO_TEST_CASE(key_signature_tests) { // When entropy is specified, we should see at least one high R signature within 20 signatures CKey key = DecodeSecret(strSecret1); - std::string msg = "A message to be signed"; - uint256 msg_hash = Hash(msg); + uint256 msg_hash = Hash("A message to be signed"); std::vector sig; bool found = false; @@ -189,8 +188,7 @@ BOOST_AUTO_TEST_CASE(key_signature_tests) bool bad_sign = false; for (int i = 0; i < 256; ++i) { sig.clear(); - std::string msg = "A message to be signed" + ToString(i); - msg_hash = Hash(msg); + msg_hash = Hash("A message to be signed" + ToString(i)); if (!key.Sign(msg_hash, sig)) { bad_sign = true; break;