mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-29 15:23:26 +02:00
Merge bitcoin/bitcoin#34684: refactor: Enable -Wswitch in exhaustive switch'es, Enable -Wcovered-switch-default
fa4ec13b44build: Enable -Wcovered-switch-default (MarcoFalke)fa2670bd4brefactor: Enable -Wswitch in exhaustive switch (MarcoFalke) Pull request description: The compiler flag `-Wswitch` is enabled. However, it can not fire when a `default:` case exists. Fix that by removing the default case where a switch is already handling all cases exhaustively. Also, enable `-Wcovered-switch-default` to catch those cases at compile time in the future. Also, apply the comment according to the dev notes. Can be reviewed via `--ignore-all-space` ACKs for top commit: stickies-v: re-ACKfa4ec13b44, no changes except for addressing silent merge conflict fromd339884f1dl0rinc: ACKfa4ec13b44achow101: ACKfa4ec13b44sedited: ACKfa4ec13b44Tree-SHA512: 8dd9e71a8cd338255f43448a59a1a4d40a9fc16e19a707cc10fb71442d4df9f82a0e5fae77868ef49cd0ea27fdd972687572c1a50b6aba7e08c6ce87576afc6a
This commit is contained in:
@@ -42,12 +42,15 @@ static void SignTransactionSingleInput(benchmark::Bench& bench, InputType input_
|
||||
keystore.pubkeys.emplace(key_id, pubkey);
|
||||
|
||||
// Create specified locking script type
|
||||
CScript prev_spk;
|
||||
switch (input_type) {
|
||||
case InputType::P2WPKH: prev_spk = GetScriptForDestination(WitnessV0KeyHash(pubkey)); break;
|
||||
case InputType::P2TR: prev_spk = GetScriptForDestination(WitnessV1Taproot(XOnlyPubKey{pubkey})); break;
|
||||
default: assert(false);
|
||||
}
|
||||
CScript prev_spk = [&]() {
|
||||
switch (input_type) {
|
||||
case InputType::P2WPKH:
|
||||
return GetScriptForDestination(WitnessV0KeyHash(pubkey));
|
||||
case InputType::P2TR:
|
||||
return GetScriptForDestination(WitnessV1Taproot(XOnlyPubKey{pubkey}));
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}();
|
||||
prev_spks.push_back(prev_spk);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,12 +41,13 @@ static void VerifyScriptBench(benchmark::Bench& bench, ScriptType script_type)
|
||||
keystore.pubkeys.emplace(key_id, pubkey);
|
||||
|
||||
// Create crediting and spending transactions with provided input type
|
||||
CTxDestination dest;
|
||||
switch (script_type) {
|
||||
case ScriptType::P2WPKH: dest = WitnessV0KeyHash(pubkey); break;
|
||||
case ScriptType::P2TR: dest = WitnessV1Taproot(XOnlyPubKey{pubkey}); break;
|
||||
default: assert(false);
|
||||
}
|
||||
const auto dest{[&]() -> CTxDestination {
|
||||
switch (script_type) {
|
||||
case ScriptType::P2WPKH: return WitnessV0KeyHash(pubkey);
|
||||
case ScriptType::P2TR: return WitnessV1Taproot(XOnlyPubKey{pubkey});
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}()};
|
||||
const CMutableTransaction& txCredit = BuildCreditingTransaction(GetScriptForDestination(dest), 1);
|
||||
CMutableTransaction txSpend = BuildSpendingTransaction(/*scriptSig=*/{}, /*scriptWitness=*/{}, CTransaction(txCredit));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user