diff options
author | fanquake <fanquake@gmail.com> | 2023-05-30 15:15:03 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-05-30 15:32:19 +0100 |
commit | 214f8f18b310e3af88eba6a005439ae423ccd76a (patch) | |
tree | f9b69846719e66215a020c65570b539f7ef3a221 /src | |
parent | 9564f98fee9809530e10070ab18738aefe95445e (diff) | |
parent | fa5680b7520c340952239c4e25ebe505d16c7c39 (diff) | |
download | bitcoin-214f8f18b310e3af88eba6a005439ae423ccd76a.tar.xz |
Merge bitcoin/bitcoin#27774: refactor: Add [[nodiscard]] where ignoring a Result return type is an error
fa5680b7520c340952239c4e25ebe505d16c7c39 fix includes for touched header files (iwyu) (MarcoFalke)
dddde27f6fbcff7cdb31f7138efc5d8363537b03 Add [[nodiscard]] where ignoring a Result return type is an error (MarcoFalke)
Pull request description:
Only add it for those where it is an error to ignore. Also, fix the gcc compile warning https://github.com/bitcoin/bitcoin/pull/25977#issuecomment-1564350880. Also, fix iwyu for touched header files.
ACKs for top commit:
TheCharlatan:
ACK fa5680b7520c340952239c4e25ebe505d16c7c39
stickies-v:
ACK fa5680b7520c340952239c4e25ebe505d16c7c39
Tree-SHA512: c3509103bfeae246e2cf565bc561fcd68d8118515bac5431ba5304c3a63c8254b9c4f40e268b6f6d6b79405675c5a960db9b4eb3bdd14aedca333dc1c9e76415
Diffstat (limited to 'src')
-rw-r--r-- | src/addrdb.cpp | 3 | ||||
-rw-r--r-- | src/addrdb.h | 6 | ||||
-rw-r--r-- | src/kernel/checks.h | 7 | ||||
-rw-r--r-- | src/node/blockmanager_args.h | 2 | ||||
-rw-r--r-- | src/node/chainstatemanager_args.h | 2 | ||||
-rw-r--r-- | src/txdb.h | 7 | ||||
-rw-r--r-- | src/wallet/wallet.h | 2 |
7 files changed, 14 insertions, 15 deletions
diff --git a/src/addrdb.cpp b/src/addrdb.cpp index fcb0f0719b..23f9600ea5 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -210,7 +210,8 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro return util::Error{strprintf(_("Invalid or corrupt peers.dat (%s). If you believe this is a bug, please report it to %s. As a workaround, you can move the file (%s) out of the way (rename, move, or delete) to have a new one created on the next start."), e.what(), PACKAGE_BUGREPORT, fs::quoted(fs::PathToString(path_addr)))}; } - return std::move(addrman); // std::move should be unneccessary but is temporarily needed to work around clang bug (https://github.com/bitcoin/bitcoin/pull/25977#issuecomment-1561270092) + return {std::move(addrman)}; // std::move should be unneccessary but is temporarily needed to work around clang bug + // (https://github.com/bitcoin/bitcoin/pull/25977#issuecomment-1561270092) } void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors) diff --git a/src/addrdb.h b/src/addrdb.h index 3da630fff8..0037495d18 100644 --- a/src/addrdb.h +++ b/src/addrdb.h @@ -6,12 +6,11 @@ #ifndef BITCOIN_ADDRDB_H #define BITCOIN_ADDRDB_H -#include <net_types.h> // For banmap_t -#include <univalue.h> +#include <net_types.h> #include <util/fs.h> #include <util/result.h> -#include <optional> +#include <memory> #include <vector> class ArgsManager; @@ -19,7 +18,6 @@ class AddrMan; class CAddress; class CDataStream; class NetGroupManager; -struct bilingual_str; bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr); /** Only used by tests. */ diff --git a/src/kernel/checks.h b/src/kernel/checks.h index 8cff4e3be4..fd8c167015 100644 --- a/src/kernel/checks.h +++ b/src/kernel/checks.h @@ -7,8 +7,6 @@ #include <util/result.h> -struct bilingual_str; - namespace kernel { struct Context; @@ -16,8 +14,7 @@ struct Context; /** * Ensure a usable environment with all necessary library support. */ -util::Result<void> SanityChecks(const Context&); - -} +[[nodiscard]] util::Result<void> SanityChecks(const Context&); +} // namespace kernel #endif // BITCOIN_KERNEL_CHECKS_H diff --git a/src/node/blockmanager_args.h b/src/node/blockmanager_args.h index 84540b1922..de9fe83a5c 100644 --- a/src/node/blockmanager_args.h +++ b/src/node/blockmanager_args.h @@ -12,7 +12,7 @@ class ArgsManager; namespace node { -util::Result<void> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts); +[[nodiscard]] util::Result<void> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts); } // namespace node #endif // BITCOIN_NODE_BLOCKMANAGER_ARGS_H diff --git a/src/node/chainstatemanager_args.h b/src/node/chainstatemanager_args.h index 82eb037368..701515953e 100644 --- a/src/node/chainstatemanager_args.h +++ b/src/node/chainstatemanager_args.h @@ -11,7 +11,7 @@ class ArgsManager; namespace node { -util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts); +[[nodiscard]] util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts); } // namespace node #endif // BITCOIN_NODE_CHAINSTATEMANAGER_ARGS_H diff --git a/src/txdb.h b/src/txdb.h index c92733a22c..04d0ecb39f 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -13,6 +13,9 @@ #include <util/fs.h> #include <util/result.h> +#include <cstddef> +#include <cstdint> +#include <functional> #include <memory> #include <optional> #include <string> @@ -21,11 +24,11 @@ class CBlockFileInfo; class CBlockIndex; +class COutPoint; class uint256; namespace Consensus { struct Params; }; -struct bilingual_str; //! -dbcache default (MiB) static const int64_t nDefaultDbCache = 450; @@ -99,6 +102,6 @@ public: EXCLUSIVE_LOCKS_REQUIRED(::cs_main); }; -util::Result<void> CheckLegacyTxindex(CBlockTreeDB& block_tree_db); +[[nodiscard]] util::Result<void> CheckLegacyTxindex(CBlockTreeDB& block_tree_db); #endif // BITCOIN_TXDB_H diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 7bf7264568..cbd5008366 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1074,7 +1074,7 @@ struct MigrationResult { }; //! Do all steps to migrate a legacy wallet to a descriptor wallet -util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& wallet_name, const SecureString& passphrase, WalletContext& context); +[[nodiscard]] util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& wallet_name, const SecureString& passphrase, WalletContext& context); } // namespace wallet #endif // BITCOIN_WALLET_WALLET_H |