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: nodejs#25968
PR-URL: nodejs#25861
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
sam-github committed Apr 29, 2019
1 parent 750b906 commit 5febe41
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 @@ -346,14 +346,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 @@ -371,8 +372,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 5febe41

Please sign in to comment.