Skip to content

Commit 214f8f1

Browse files
committed
Merge bitcoin/bitcoin#27774: refactor: Add [[nodiscard]] where ignoring a Result return type is an error
fa5680b fix includes for touched header files (iwyu) (MarcoFalke) dddde27 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 bitcoin/bitcoin#25977 (comment). Also, fix iwyu for touched header files. ACKs for top commit: TheCharlatan: ACK fa5680b stickies-v: ACK fa5680b Tree-SHA512: c3509103bfeae246e2cf565bc561fcd68d8118515bac5431ba5304c3a63c8254b9c4f40e268b6f6d6b79405675c5a960db9b4eb3bdd14aedca333dc1c9e76415
2 parents 9564f98 + fa5680b commit 214f8f1

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

src/addrdb.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro
210210
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."),
211211
e.what(), PACKAGE_BUGREPORT, fs::quoted(fs::PathToString(path_addr)))};
212212
}
213-
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)
213+
return {std::move(addrman)}; // std::move should be unneccessary but is temporarily needed to work around clang bug
214+
// (https://github.com/bitcoin/bitcoin/pull/25977#issuecomment-1561270092)
214215
}
215216

216217
void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors)

src/addrdb.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,18 @@
66
#ifndef BITCOIN_ADDRDB_H
77
#define BITCOIN_ADDRDB_H
88

9-
#include <net_types.h> // For banmap_t
10-
#include <univalue.h>
9+
#include <net_types.h>
1110
#include <util/fs.h>
1211
#include <util/result.h>
1312

14-
#include <optional>
13+
#include <memory>
1514
#include <vector>
1615

1716
class ArgsManager;
1817
class AddrMan;
1918
class CAddress;
2019
class CDataStream;
2120
class NetGroupManager;
22-
struct bilingual_str;
2321

2422
bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr);
2523
/** Only used by tests. */

src/kernel/checks.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77

88
#include <util/result.h>
99

10-
struct bilingual_str;
11-
1210
namespace kernel {
1311

1412
struct Context;
1513

1614
/**
1715
* Ensure a usable environment with all necessary library support.
1816
*/
19-
util::Result<void> SanityChecks(const Context&);
20-
21-
}
17+
[[nodiscard]] util::Result<void> SanityChecks(const Context&);
18+
} // namespace kernel
2219

2320
#endif // BITCOIN_KERNEL_CHECKS_H

src/node/blockmanager_args.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ArgsManager;
1313

1414
namespace node {
15-
util::Result<void> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts);
15+
[[nodiscard]] util::Result<void> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts);
1616
} // namespace node
1717

1818
#endif // BITCOIN_NODE_BLOCKMANAGER_ARGS_H

src/node/chainstatemanager_args.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class ArgsManager;
1212

1313
namespace node {
14-
util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts);
14+
[[nodiscard]] util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts);
1515
} // namespace node
1616

1717
#endif // BITCOIN_NODE_CHAINSTATEMANAGER_ARGS_H

src/txdb.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <util/fs.h>
1414
#include <util/result.h>
1515

16+
#include <cstddef>
17+
#include <cstdint>
18+
#include <functional>
1619
#include <memory>
1720
#include <optional>
1821
#include <string>
@@ -21,11 +24,11 @@
2124

2225
class CBlockFileInfo;
2326
class CBlockIndex;
27+
class COutPoint;
2428
class uint256;
2529
namespace Consensus {
2630
struct Params;
2731
};
28-
struct bilingual_str;
2932

3033
//! -dbcache default (MiB)
3134
static const int64_t nDefaultDbCache = 450;
@@ -99,6 +102,6 @@ class CBlockTreeDB : public CDBWrapper
99102
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
100103
};
101104

102-
util::Result<void> CheckLegacyTxindex(CBlockTreeDB& block_tree_db);
105+
[[nodiscard]] util::Result<void> CheckLegacyTxindex(CBlockTreeDB& block_tree_db);
103106

104107
#endif // BITCOIN_TXDB_H

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ struct MigrationResult {
10741074
};
10751075

10761076
//! Do all steps to migrate a legacy wallet to a descriptor wallet
1077-
util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& wallet_name, const SecureString& passphrase, WalletContext& context);
1077+
[[nodiscard]] util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& wallet_name, const SecureString& passphrase, WalletContext& context);
10781078
} // namespace wallet
10791079

10801080
#endif // BITCOIN_WALLET_WALLET_H

0 commit comments

Comments
 (0)