fafb9c6 scripted-diff: Replace falsy assertions with AssertUnreachable:
nit: same comment as in to_btck for consistency?
<details>
<summary>Explain the omitted defaults</summary>
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index f68dc7b8b4..84ce94e240 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -441,7 +441,7 @@ private:
return " regtest";
case ChainType::MAIN:
return "";
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
std::string PingTimeToString(double seconds) const
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 7d255d623f..fed439c7ab 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -158,7 +158,7 @@ std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, c
ReadRegTestArgs(args, opts);
return CChainParams::RegTest(opts);
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp
index 61889bdd82..70ccc1287e 100644
--- a/src/chainparamsbase.cpp
+++ b/src/chainparamsbase.cpp
@@ -71,7 +71,7 @@ std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ArgsManager& args,
return std::make_unique<CBaseChainParams>(GetSignetDataDir(args), 38332);
case ChainType::REGTEST:
return std::make_unique<CBaseChainParams>("regtest", 18443);
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp
index 732e7074fa..27f3272c1a 100644
--- a/src/kernel/bitcoinkernel.cpp
+++ b/src/kernel/bitcoinkernel.cpp
@@ -179,7 +179,7 @@ constexpr util::log::Level to_util(btck_LogLevel level)
case btck_LogLevel_ERROR: {
return util::log::Level::Error;
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
@@ -1066,7 +1066,7 @@ btck_ChainParameters* btck_chain_parameters_create(const btck_ChainType chain_ty
case btck_ChainType_REGTEST: {
return btck_ChainParameters::ref(const_cast<CChainParams*>(CChainParams::RegTest().release()));
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/kernel/mempool_removal_reason.cpp b/src/kernel/mempool_removal_reason.cpp
index a078d081b2..9c32172893 100644
--- a/src/kernel/mempool_removal_reason.cpp
+++ b/src/kernel/mempool_removal_reason.cpp
@@ -17,6 +17,6 @@ std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept
case MemPoolRemovalReason::BLOCK: return "block";
case MemPoolRemovalReason::CONFLICT: return "conflict";
case MemPoolRemovalReason::REPLACED: return "replaced";
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/logging.cpp b/src/logging.cpp
index edf799c800..de5ae7f67b 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -254,7 +254,7 @@ std::string BCLog::Logger::LogLevelToStr(BCLog::Level level)
return "warning";
case BCLog::Level::Error:
return "error";
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp
index 014b4df4db..1e347ac9df 100644
--- a/src/script/descriptor.cpp
+++ b/src/script/descriptor.cpp
@@ -2331,7 +2331,7 @@ struct KeyParser {
switch (m_script_ctx) {
case miniscript::MiniscriptContext::P2WSH: return ParseScriptContext::P2WSH;
case miniscript::MiniscriptContext::TAPSCRIPT: return ParseScriptContext::P2TR;
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/script/miniscript.cpp b/src/script/miniscript.cpp
index 6dfa6832b4..7e34ac35d1 100644
--- a/src/script/miniscript.cpp
+++ b/src/script/miniscript.cpp
@@ -257,7 +257,7 @@ Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector<Ty
"s"_mst.If(num_s >= n_subs - k + 1) | // s= >=(n-k+1) s
acc_tl; // timelock info
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
@@ -291,7 +291,7 @@ size_t ComputeScriptLen(Fragment fragment, Type sub0typ, size_t subsize, uint32_
case Fragment::ANDOR: return subsize + 3;
case Fragment::WRAP_J: return subsize + 4;
case Fragment::THRESH: return subsize + n_subs + BuildScript(k).size();
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/script/miniscript.h b/src/script/miniscript.h
index 1ac4d71eec..1a24d39bfc 100644
--- a/src/script/miniscript.h
+++ b/src/script/miniscript.h
@@ -261,7 +261,7 @@ constexpr bool IsTapscript(MiniscriptContext ms_ctx)
switch (ms_ctx) {
case MiniscriptContext::P2WSH: return false;
case MiniscriptContext::TAPSCRIPT: return true;
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
@@ -867,7 +867,7 @@ public:
}
return BuildScript(std::move(script), node.k, verify ? OP_EQUALVERIFY : OP_EQUAL);
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
};
return TreeEval<CScript>(false, downfn, upfn);
@@ -1071,7 +1071,7 @@ private:
assert(k < sats.size());
return {count, sats[k], sats[0]};
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
@@ -1186,7 +1186,7 @@ private:
sats[0] + SatInfo::Push() + SatInfo::OP_EQUAL()
};
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
@@ -1239,7 +1239,7 @@ private:
assert(k < sats.size());
return {sats[k], sats[0]};
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
@@ -1440,7 +1440,7 @@ private:
}
case Fragment::JUST_0: return {EMPTY, INVALID};
case Fragment::JUST_1: return {INVALID, EMPTY};
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
};
diff --git a/src/test/fuzz/http_request.cpp b/src/test/fuzz/http_request.cpp
index fcdcd1a4e5..88627d81cf 100644
--- a/src/test/fuzz/http_request.cpp
+++ b/src/test/fuzz/http_request.cpp
@@ -82,7 +82,7 @@ int StateRank(HTTPRequest::State s)
case HTTPRequest::State::NeedsBody: return 2;
case HTTPRequest::State::Complete: return 3;
case HTTPRequest::State::Error: return 4;
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/test/fuzz/miniscript.cpp b/src/test/fuzz/miniscript.cpp
index 77c34415f0..22d86aabca 100644
--- a/src/test/fuzz/miniscript.cpp
+++ b/src/test/fuzz/miniscript.cpp
@@ -834,7 +834,7 @@ std::optional<NodeInfo> ConsumeNodeSmart(MsCtx script_ctx, FuzzedDataProvider& p
while (subs.size() < children) subs.push_back(subs.back());
return {{std::move(subs), frag, k}};
}
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/util/chaintype.cpp b/src/util/chaintype.cpp
index 7078a50c8f..5391c2e8ba 100644
--- a/src/util/chaintype.cpp
+++ b/src/util/chaintype.cpp
@@ -22,7 +22,7 @@ std::string ChainTypeToString(ChainType chain)
return "signet";
case ChainType::REGTEST:
return "regtest";
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
diff --git a/src/validation.cpp b/src/validation.cpp
index 89deea5215..5ff03f9c3e 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2110,7 +2110,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
return state.Invalid(TxValidationResult::TX_NOT_STANDARD, strprintf("mempool-script-verify-flag-failed (%s)", ScriptErrorString(result->first)), result->second);
case CheckInputScriptsFor::Block:
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(result->first)), result->second);
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
}
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 66deb1c9bc..9274c39204 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -209,7 +209,7 @@ bool LegacyDataSPKM::IsMine(const CScript& script) const
case IsMineResult::WATCH_ONLY:
case IsMineResult::SPENDABLE:
return true;
- }
+ } // no default case, so the compiler can warn about missing cases
AssertUnreachable();
}
</details>