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 <fedor.indutny@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
sam-github committed Feb 7, 2019
1 parent 2b1f881 commit 22f6d4d
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 22f6d4d

Please sign in to comment.