Skip to content

Commit

Permalink
Bug 1345478 - Make the PrintErrorKind::Error case explicitly unreacha…
Browse files Browse the repository at this point in the history
…ble in PrintSingleError; r=bbouvier

This patch explicitly calls MOZ_CRASH() in the switch case
PrintErrorKind::Error that is never reached inside the function
PrintSingleError in the file js/src/jscntxt.cpp.
Explicitly handling all the possible cases avoids the compiler to issue
warnings for them: a non handled case in the switch code that might derive
from additions to the enum class PrintErrorKind can be caught at compile time
rather then having a default switch case for handling it, which instead would
be called at runtime.

MozReview-Commit-ID: ECZlMoLvn2m

UltraBlame original commit: 1741441028b5e0713da9d93f175c0f8c79e87749
  • Loading branch information
marco-c committed Oct 1, 2019
1 parent 54dae37 commit 55f9d60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/src/jscntxt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ PrintSingleError(JSContext* cx, FILE* file, JS::ConstUTF8CharsZ toStringResult,
const char* kindPrefix = nullptr;
switch (kind) {
case PrintErrorKind::Error:
break;
MOZ_CRASH("unreachable");
case PrintErrorKind::Warning:
kindPrefix = "warning";
break;
Expand Down

0 comments on commit 55f9d60

Please sign in to comment.