Merge bitcoin/bitcoin#34684: refactor: Enable -Wswitch in exhaustive switch'es, Enable -Wcovered-switch-default

fa4ec13b44 build: Enable -Wcovered-switch-default (MarcoFalke)
fa2670bd4b refactor: 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-ACK fa4ec13b44, no changes except for addressing silent merge conflict from d339884f1d
  l0rinc:
    ACK fa4ec13b44
  achow101:
    ACK fa4ec13b44
  sedited:
    ACK fa4ec13b44

Tree-SHA512: 8dd9e71a8cd338255f43448a59a1a4d40a9fc16e19a707cc10fb71442d4df9f82a0e5fae77868ef49cd0ea27fdd972687572c1a50b6aba7e08c6ce87576afc6a
This commit is contained in:
Ava Chow
2026-03-19 14:15:38 -07:00
21 changed files with 116 additions and 125 deletions

View File

@@ -151,9 +151,8 @@ std::string GetOpName(opcodetype opcode)
case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE";
default:
return "OP_UNKNOWN";
}
} // no default case, so the compiler can warn about missing cases
return "OP_UNKNOWN";
}
unsigned int CScript::GetSigOpCount(bool fAccurate) const

View File

@@ -121,7 +121,7 @@ std::string ScriptErrorString(const ScriptError serror)
return "Script number overflowed or is non-minimally encoded";
case SCRIPT_ERR_UNKNOWN_ERROR:
case SCRIPT_ERR_ERROR_COUNT:
default: break;
}
break;
} // no default case, so the compiler can warn about missing cases
return "unknown error";
}