From dddde27f6fbcff7cdb31f7138efc5d8363537b03 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 29 May 2023 13:15:47 +0200 Subject: [PATCH] Add [[nodiscard]] where ignoring a Result return type is an error --- src/addrdb.cpp | 3 ++- src/kernel/checks.h | 5 ++--- src/node/blockmanager_args.h | 2 +- src/node/chainstatemanager_args.h | 2 +- src/txdb.h | 2 +- src/wallet/wallet.h | 2 +- 6 files changed, 8 insertions(+), 8 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> 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& anchors) diff --git a/src/kernel/checks.h b/src/kernel/checks.h index 8cff4e3be4..216aad7341 100644 --- a/src/kernel/checks.h +++ b/src/kernel/checks.h @@ -16,8 +16,7 @@ struct Context; /** * Ensure a usable environment with all necessary library support. */ -util::Result SanityChecks(const Context&); - -} +[[nodiscard]] util::Result 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 ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts); +[[nodiscard]] util::Result 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 ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts); +[[nodiscard]] util::Result 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..c65101618c 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -99,6 +99,6 @@ public: EXCLUSIVE_LOCKS_REQUIRED(::cs_main); }; -util::Result CheckLegacyTxindex(CBlockTreeDB& block_tree_db); +[[nodiscard]] util::Result 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 MigrateLegacyToDescriptor(const std::string& wallet_name, const SecureString& passphrase, WalletContext& context); +[[nodiscard]] util::Result MigrateLegacyToDescriptor(const std::string& wallet_name, const SecureString& passphrase, WalletContext& context); } // namespace wallet #endif // BITCOIN_WALLET_WALLET_H