aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-03-22 11:22:06 +0800
committerfanquake <fanquake@gmail.com>2021-03-22 11:22:06 +0800
commit5294f0d5a94cc7beaf692131fba0cad8beec9f13 (patch)
treeab68899a7525ad0a6747aaba04762dc98c73e032
parentd2a78ee9288e4d3bace9125bcfae6b7747f85982 (diff)
downloadbitcoin-5294f0d5a94cc7beaf692131fba0cad8beec9f13.tar.xz
refactor: return std::nullopt instead of {}
In #21415 we decided to return `std::optional` rather than `{}` for uninitialized values. This PR repalces 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 {}; | ^ ```
-rw-r--r--src/txmempool.cpp2
-rw-r--r--src/validation.cpp2
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()