Skip to content

Commit 81d5af4

Browse files
author
MarcoFalke
committed
Merge #20499: Remove obsolete NODISCARD ifdef forest. Use [[nodiscard]] (C++17).
79bff8e Remove NODISCARD (practicalswift) 4848e71 scripted-diff: Use [[nodiscard]] (C++17) instead of NODISCARD (practicalswift) Pull request description: Remove obsolete `NODISCARD` `ifdef` forest. Use `[[nodiscard]]` (C++17). ACKs for top commit: theStack: ACK 79bff8e fanquake: ACK 79bff8e Tree-SHA512: 56dbb8e50ed97ecfbce28cdc688a01146108acae49a943e338a8f983f7168914710d36e38632f6a7c200ba6c6ac35b2519e97d6c985e8e7eb23223f13bf985d6
2 parents 817aeca + 79bff8e commit 81d5af4

18 files changed

+54
-67
lines changed

src/attributes.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,6 @@
66
#ifndef BITCOIN_ATTRIBUTES_H
77
#define BITCOIN_ATTRIBUTES_H
88

9-
#if defined(__has_cpp_attribute)
10-
# if __has_cpp_attribute(nodiscard)
11-
# define NODISCARD [[nodiscard]]
12-
# endif
13-
#endif
14-
#ifndef NODISCARD
15-
# if defined(_MSC_VER) && _MSC_VER >= 1700
16-
# define NODISCARD _Check_return_
17-
# else
18-
# define NODISCARD __attribute__((warn_unused_result))
19-
# endif
20-
#endif
21-
229
#if defined(__clang__)
2310
# if __has_attribute(lifetimebound)
2411
# define LIFETIMEBOUND [[clang::lifetimebound]]

src/base58.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static const int8_t mapBase58[256] = {
3535
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
3636
};
3737

38-
NODISCARD static bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch, int max_ret_len)
38+
[[nodiscard]] static bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch, int max_ret_len)
3939
{
4040
// Skip leading spaces.
4141
while (*psz && IsSpace(*psz))
@@ -141,7 +141,7 @@ std::string EncodeBase58Check(Span<const unsigned char> input)
141141
return EncodeBase58(vch);
142142
}
143143

144-
NODISCARD static bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len)
144+
[[nodiscard]] static bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len)
145145
{
146146
if (!DecodeBase58(psz, vchRet, max_ret_len > std::numeric_limits<int>::max() - 4 ? std::numeric_limits<int>::max() : max_ret_len + 4) ||
147147
(vchRet.size() < 4)) {

src/base58.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ std::string EncodeBase58(Span<const unsigned char> input);
2929
* Decode a base58-encoded string (str) into a byte vector (vchRet).
3030
* return true if decoding is successful.
3131
*/
32-
NODISCARD bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len);
32+
[[nodiscard]] bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len);
3333

3434
/**
3535
* Encode a byte span into a base58-encoded string, including checksum
@@ -40,6 +40,6 @@ std::string EncodeBase58Check(Span<const unsigned char> input);
4040
* Decode a base58-encoded string (str) that includes a checksum into a byte
4141
* vector (vchRet), return true if decoding is successful
4242
*/
43-
NODISCARD bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len);
43+
[[nodiscard]] bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len);
4444

4545
#endif // BITCOIN_BASE58_H

src/core_io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class UniValue;
2222
// core_read.cpp
2323
CScript ParseScript(const std::string& s);
2424
std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false);
25-
NODISCARD bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true);
26-
NODISCARD bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
25+
[[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true);
26+
[[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
2727
bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
2828

2929
/**

src/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL
197197
}
198198

199199
/** Single-SHA256 a 32-byte input (represented as uint256). */
200-
NODISCARD uint256 SHA256Uint256(const uint256& input);
200+
[[nodiscard]] uint256 SHA256Uint256(const uint256& input);
201201

202202
unsigned int MurmurHash3(unsigned int nHashSeed, Span<const unsigned char> vDataToHash);
203203

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static fs::path GetPidFile(const ArgsManager& args)
113113
return AbsPathForConfigVal(fs::path(args.GetArg("-pid", BITCOIN_PID_FILENAME)));
114114
}
115115

116-
NODISCARD static bool CreatePidFile(const ArgsManager& args)
116+
[[nodiscard]] static bool CreatePidFile(const ArgsManager& args)
117117
{
118118
fsbridge::ofstream file{GetPidFile(args)};
119119
if (file) {

src/node/transaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10};
3636
* @param[in] wait_callback wait until callbacks have been processed to avoid stale result due to a sequentially RPC.
3737
* return error
3838
*/
39-
NODISCARD TransactionError BroadcastTransaction(NodeContext& node, CTransactionRef tx, std::string& err_string, const CAmount& max_tx_fee, bool relay, bool wait_callback);
39+
[[nodiscard]] TransactionError BroadcastTransaction(NodeContext& node, CTransactionRef tx, std::string& err_string, const CAmount& max_tx_fee, bool relay, bool wait_callback);
4040

4141
#endif // BITCOIN_NODE_TRANSACTION_H

src/outputtype.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ enum class OutputType {
2222

2323
extern const std::array<OutputType, 3> OUTPUT_TYPES;
2424

25-
NODISCARD bool ParseOutputType(const std::string& str, OutputType& output_type);
25+
[[nodiscard]] bool ParseOutputType(const std::string& str, OutputType& output_type);
2626
const std::string& FormatOutputType(OutputType type);
2727

2828
/**

src/psbt.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ struct PartiallySignedTransaction
398398

399399
/** Merge psbt into this. The two psbts must have the same underlying CTransaction (i.e. the
400400
* same actual Bitcoin transaction.) Returns true if the merge succeeded, false otherwise. */
401-
NODISCARD bool Merge(const PartiallySignedTransaction& psbt);
401+
[[nodiscard]] bool Merge(const PartiallySignedTransaction& psbt);
402402
bool AddInput(const CTxIn& txin, PSBTInput& psbtin);
403403
bool AddOutput(const CTxOut& txout, const PSBTOutput& psbtout);
404404
PartiallySignedTransaction() {}
@@ -605,11 +605,11 @@ bool FinalizeAndExtractPSBT(PartiallySignedTransaction& psbtx, CMutableTransacti
605605
* @param[in] psbtxs the PSBTs to combine
606606
* @return error (OK if we successfully combined the transactions, other error if they were not compatible)
607607
*/
608-
NODISCARD TransactionError CombinePSBTs(PartiallySignedTransaction& out, const std::vector<PartiallySignedTransaction>& psbtxs);
608+
[[nodiscard]] TransactionError CombinePSBTs(PartiallySignedTransaction& out, const std::vector<PartiallySignedTransaction>& psbtxs);
609609

610610
//! Decode a base64ed PSBT into a PartiallySignedTransaction
611-
NODISCARD bool DecodeBase64PSBT(PartiallySignedTransaction& decoded_psbt, const std::string& base64_psbt, std::string& error);
611+
[[nodiscard]] bool DecodeBase64PSBT(PartiallySignedTransaction& decoded_psbt, const std::string& base64_psbt, std::string& error);
612612
//! Decode a raw (binary blob) PSBT into a PartiallySignedTransaction
613-
NODISCARD bool DecodeRawPSBT(PartiallySignedTransaction& decoded_psbt, const std::string& raw_psbt, std::string& error);
613+
[[nodiscard]] bool DecodeRawPSBT(PartiallySignedTransaction& decoded_psbt, const std::string& raw_psbt, std::string& error);
614614

615615
#endif // BITCOIN_PSBT_H

src/script/descriptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ enum class ParseScriptContext {
731731
};
732732

733733
/** Parse a key path, being passed a split list of elements (the first element is ignored). */
734-
NODISCARD bool ParseKeyPath(const std::vector<Span<const char>>& split, KeyPath& out, std::string& error)
734+
[[nodiscard]] bool ParseKeyPath(const std::vector<Span<const char>>& split, KeyPath& out, std::string& error)
735735
{
736736
for (size_t i = 1; i < split.size(); ++i) {
737737
Span<const char> elem = split[i];

0 commit comments

Comments
 (0)