Skip to content

Commit 786654a

Browse files
author
MarcoFalke
committed
Merge #21498: refactor: return std::nullopt instead of {}
5294f0d refactor: return std::nullopt instead of {} (fanquake) Pull request description: In #21415 [we decided](bitcoin/bitcoin#21415 (comment)) 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 5294f0d, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 5b776be79ab26e5a3a5fc2b463b394ea5ce6797ed5558424873fa4ecee2898170eff76d6da9d69394d28f8f98974117fc63b922a3e19c52f5294c83073e79bb0
2 parents 80cb51c + 5294f0d commit 786654a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/txmempool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
895895
{
896896
auto it = mapTx.find(txid);
897897
if (it != mapTx.end()) return it;
898-
return {};
898+
return std::nullopt;
899899
}
900900

901901
CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>& hashes) const

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5186,7 +5186,7 @@ std::optional<uint256> ChainstateManager::SnapshotBlockhash() const {
51865186
// If a snapshot chainstate exists, it will always be our active.
51875187
return m_active_chainstate->m_from_snapshot_blockhash;
51885188
}
5189-
return {};
5189+
return std::nullopt;
51905190
}
51915191

51925192
std::vector<CChainState*> ChainstateManager::GetAll()

0 commit comments

Comments
 (0)