diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-03-22 06:42:01 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-03-22 06:42:04 +0100 |
commit | 786654aa5e0b7a7f91404e8fb9c3b2a7f7a421ba (patch) | |
tree | 2cb8954fa798770bfa7104c804cc666572538446 /src | |
parent | 80cb51cc6b417fb7b23fc8b299f0605e7f82c62d (diff) | |
parent | 5294f0d5a94cc7beaf692131fba0cad8beec9f13 (diff) | |
download | bitcoin-786654aa5e0b7a7f91404e8fb9c3b2a7f7a421ba.tar.xz |
Merge #21498: refactor: return std::nullopt instead of {}
5294f0d5a94cc7beaf692131fba0cad8beec9f13 refactor: return std::nullopt instead of {} (fanquake)
Pull request description:
In #21415 [we decided](https://github.com/bitcoin/bitcoin/pull/21415#issuecomment-800236640) to return `std::optional` rather than `{}` for
uninitialized values. This PR replaces the two remaining usages of `{}`
with `std::nullopt`.
As a side-effect, this also quells the spurious GCC 10.2.x warning that
we've had reported quite a few times. i.e #21318, #21248, #20797.
```bash
txmempool.cpp: In member function ‘CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>&) const’:
txmempool.cpp:898:13: warning: ‘<anonymous>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
898 | return {};
| ^
```
ACKs for top commit:
hebasto:
ACK 5294f0d5a94cc7beaf692131fba0cad8beec9f13, I have reviewed the code and it looks OK, I agree it can be merged.
Tree-SHA512: 5b776be79ab26e5a3a5fc2b463b394ea5ce6797ed5558424873fa4ecee2898170eff76d6da9d69394d28f8f98974117fc63b922a3e19c52f5294c83073e79bb0
Diffstat (limited to 'src')
-rw-r--r-- | src/txmempool.cpp | 2 | ||||
-rw-r--r-- | src/validation.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index faccd1ade0..67549fc13d 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -895,7 +895,7 @@ std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const { auto it = mapTx.find(txid); if (it != mapTx.end()) return it; - return {}; + return std::nullopt; } CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>& hashes) const diff --git a/src/validation.cpp b/src/validation.cpp index 96d12f10e2..d1b9efe7ba 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5186,7 +5186,7 @@ std::optional<uint256> ChainstateManager::SnapshotBlockhash() const { // If a snapshot chainstate exists, it will always be our active. return m_active_chainstate->m_from_snapshot_blockhash; } - return {}; + return std::nullopt; } std::vector<CChainState*> ChainstateManager::GetAll() |