From 16a9f65d2edb96b7b9962ede2cdc1dc7814c7976 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 6 Oct 2018 16:12:13 -0400 Subject: [PATCH] src: remove unneeded variables in node_crypto.cc PR-URL: https://github.com/nodejs/node/pull/23297 Reviewed-By: Anna Henningsen Reviewed-By: Joyee Cheung Reviewed-By: Refael Ackermann Reviewed-By: Gabriel Schulhof Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- src/node_crypto.cc | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 2e3280f313db3a..c669dccde783bc 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -573,17 +573,13 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx, if (ret) { // If we could set up our certificate, now proceed to // the CA certificates. - int r; - SSL_CTX_clear_extra_chain_certs(ctx); for (int i = 0; i < sk_X509_num(extra_certs); i++) { X509* ca = sk_X509_value(extra_certs, i); // NOTE: Increments reference count on `ca` - r = SSL_CTX_add1_chain_cert(ctx, ca); - - if (!r) { + if (!SSL_CTX_add1_chain_cert(ctx, ca)) { ret = 0; issuer = nullptr; break; @@ -1580,15 +1576,11 @@ static Local X509ToObject(Environment* env, X509* cert) { if (index < 0) continue; - X509_EXTENSION* ext; - int rv; - - ext = X509_get_ext(cert, index); + X509_EXTENSION* ext = X509_get_ext(cert, index); CHECK_NOT_NULL(ext); if (!SafeX509ExtPrint(bio.get(), ext)) { - rv = X509V3_EXT_print(bio.get(), ext, 0, 0); - CHECK_EQ(rv, 1); + CHECK_EQ(1, X509V3_EXT_print(bio.get(), ext, 0, 0)); } BIO_get_mem_ptr(bio.get(), &mem); @@ -3746,7 +3738,6 @@ SignBase::Error Verify::VerifyFinal(const char* key_pem, EVPKeyPointer pkey; unsigned char m[EVP_MAX_MD_SIZE]; unsigned int m_len; - int r = 0; *verify_result = false; EVPMDPointer mdctx = std::move(mdctx_); @@ -3762,11 +3753,11 @@ SignBase::Error Verify::VerifyFinal(const char* key_pem, ApplyRSAOptions(pkey, pkctx.get(), padding, saltlen) && EVP_PKEY_CTX_set_signature_md(pkctx.get(), EVP_MD_CTX_md(mdctx.get())) > 0) { - r = EVP_PKEY_verify(pkctx.get(), - reinterpret_cast(sig), - siglen, - m, - m_len); + const int r = EVP_PKEY_verify(pkctx.get(), + reinterpret_cast(sig), + siglen, + m, + m_len); *verify_result = r == 1; }