From 5294f0d5a94cc7beaf692131fba0cad8beec9f13 Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 22 Mar 2021 11:22:06 +0800 Subject: refactor: return std::nullopt instead of {} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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&) const’: txmempool.cpp:898:13: warning: ‘’ may be used uninitialized in this function [-Wmaybe-uninitialized] 898 | return {}; | ^ ``` --- src/txmempool.cpp | 2 +- src/validation.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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::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& 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 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 ChainstateManager::GetAll() -- cgit v1.2.3