Skip to content

Commit

Permalink
src: refactor SSLError case statement
Browse files Browse the repository at this point in the history
- Don't use both break and return simultaneously.
- Use case:/UNREACHABLE() to enforce that all cases are handled, instead
  of CHECK().

Backport-PR-URL: #25968
PR-URL: #25861
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>

Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
sam-github authored and addaleax committed Feb 8, 2019
1 parent 0b4055e commit 7cf484c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,15 @@ Local<Value> TLSWrap::GetSSLError(int status, int* err, std::string* msg) {
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_X509_LOOKUP:
break;
return Local<Value>();

case SSL_ERROR_ZERO_RETURN:
return scope.Escape(env()->zero_return_string());
break;
default:
{
CHECK(*err == SSL_ERROR_SSL || *err == SSL_ERROR_SYSCALL);

case SSL_ERROR_SSL:
case SSL_ERROR_SYSCALL:
{
unsigned long ssl_err = ERR_peek_error(); // NOLINT(runtime/int)
BIO* bio = BIO_new(BIO_s_mem());
ERR_print_errors(bio);

Expand All @@ -372,8 +373,11 @@ Local<Value> TLSWrap::GetSSLError(int status, int* err, std::string* msg) {

return scope.Escape(exception);
}

default:
UNREACHABLE();
}
return Local<Value>();
UNREACHABLE();
}


Expand Down

0 comments on commit 7cf484c

Please sign in to comment.