mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-14 07:54:12 +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:
@@ -583,29 +583,29 @@ RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector<RP
|
||||
// Default value type should match argument type only when defined
|
||||
if (arg.m_fallback.index() == 2) {
|
||||
const RPCArg::Type type = arg.m_type;
|
||||
switch (std::get<RPCArg::Default>(arg.m_fallback).getType()) {
|
||||
case UniValue::VOBJ:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::OBJ);
|
||||
break;
|
||||
case UniValue::VARR:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::ARR);
|
||||
break;
|
||||
case UniValue::VSTR:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::STR || type == RPCArg::Type::STR_HEX || type == RPCArg::Type::AMOUNT);
|
||||
break;
|
||||
case UniValue::VNUM:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::NUM || type == RPCArg::Type::AMOUNT || type == RPCArg::Type::RANGE);
|
||||
break;
|
||||
case UniValue::VBOOL:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::BOOL);
|
||||
break;
|
||||
case UniValue::VNULL:
|
||||
// Null values are accepted in all arguments
|
||||
break;
|
||||
default:
|
||||
[&]() {
|
||||
switch (std::get<RPCArg::Default>(arg.m_fallback).getType()) {
|
||||
case UniValue::VOBJ:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::OBJ);
|
||||
return;
|
||||
case UniValue::VARR:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::ARR);
|
||||
return;
|
||||
case UniValue::VSTR:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::STR || type == RPCArg::Type::STR_HEX || type == RPCArg::Type::AMOUNT);
|
||||
return;
|
||||
case UniValue::VNUM:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::NUM || type == RPCArg::Type::AMOUNT || type == RPCArg::Type::RANGE);
|
||||
return;
|
||||
case UniValue::VBOOL:
|
||||
CHECK_NONFATAL(type == RPCArg::Type::BOOL);
|
||||
return;
|
||||
case UniValue::VNULL:
|
||||
// Null values are accepted in all arguments
|
||||
return;
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
NONFATAL_UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user