diff --git a/src/async_wrap.cc b/src/async_wrap.cc index b355841c3419d0..607d4792192d18 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -173,8 +173,7 @@ void AsyncWrap::EmitPromiseResolve(Environment* env, double async_id) { Local async_id_value = Number::New(env->isolate(), async_id); Local fn = env->async_hooks_promise_resolve_function(); FatalTryCatch try_catch(env); - fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value) - .FromMaybe(Local()); + USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)); } @@ -202,8 +201,7 @@ void AsyncWrap::EmitBefore(Environment* env, double async_id) { Local async_id_value = Number::New(env->isolate(), async_id); Local fn = env->async_hooks_before_function(); FatalTryCatch try_catch(env); - fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value) - .FromMaybe(Local()); + USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)); } @@ -233,8 +231,7 @@ void AsyncWrap::EmitAfter(Environment* env, double async_id) { Local async_id_value = Number::New(env->isolate(), async_id); Local fn = env->async_hooks_after_function(); FatalTryCatch try_catch(env); - fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value) - .FromMaybe(Local()); + USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)); } class PromiseWrap : public AsyncWrap { @@ -736,8 +733,7 @@ void AsyncWrap::EmitAsyncInit(Environment* env, }; FatalTryCatch try_catch(env); - init_fn->Call(env->context(), object, arraysize(argv), argv) - .FromMaybe(Local()); + USE(init_fn->Call(env->context(), object, arraysize(argv), argv)); } diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 1f868afbed4d03..5db3db3ed51d20 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1827,7 +1827,7 @@ static Local X509ToObject(Environment* env, X509* cert) { String::NewFromUtf8(env->isolate(), mem->data, String::kNormalString, mem->length)); } - (void) BIO_reset(bio); + USE(BIO_reset(bio)); X509_NAME* issuer_name = X509_get_issuer_name(cert); if (X509_NAME_print_ex(bio, issuer_name, 0, X509_NAME_FLAGS) > 0) { @@ -1836,7 +1836,7 @@ static Local X509ToObject(Environment* env, X509* cert) { String::NewFromUtf8(env->isolate(), mem->data, String::kNormalString, mem->length)); } - (void) BIO_reset(bio); + USE(BIO_reset(bio)); int nids[] = { NID_subject_alt_name, NID_info_access }; Local keys[] = { env->subjectaltname_string(), @@ -1863,7 +1863,7 @@ static Local X509ToObject(Environment* env, X509* cert) { String::NewFromUtf8(env->isolate(), mem->data, String::kNormalString, mem->length)); - (void) BIO_reset(bio); + USE(BIO_reset(bio)); } EVP_PKEY* pkey = X509_get_pubkey(cert); @@ -1880,7 +1880,7 @@ static Local X509ToObject(Environment* env, X509* cert) { info->Set(env->modulus_string(), String::NewFromUtf8(env->isolate(), mem->data, String::kNormalString, mem->length)); - (void) BIO_reset(bio); + USE(BIO_reset(bio)); uint64_t exponent_word = static_cast(BN_get_word(e)); uint32_t lo = static_cast(exponent_word); @@ -1894,7 +1894,7 @@ static Local X509ToObject(Environment* env, X509* cert) { info->Set(env->exponent_string(), String::NewFromUtf8(env->isolate(), mem->data, String::kNormalString, mem->length)); - (void) BIO_reset(bio); + USE(BIO_reset(bio)); } if (pkey != nullptr) { @@ -1911,7 +1911,7 @@ static Local X509ToObject(Environment* env, X509* cert) { info->Set(env->valid_from_string(), String::NewFromUtf8(env->isolate(), mem->data, String::kNormalString, mem->length)); - (void) BIO_reset(bio); + USE(BIO_reset(bio)); ASN1_TIME_print(bio, X509_get_notAfter(cert)); BIO_get_mem_ptr(bio, &mem); @@ -2889,7 +2889,7 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) { return rv; int retry = BIO_should_retry(bio); - (void) retry; // unused if !defined(SSL_PRINT_DEBUG) + USE(retry); // unused if !defined(SSL_PRINT_DEBUG) if (BIO_should_write(bio)) { DEBUG_PRINT("[%p] BIO: %s want write. should retry %d\n", @@ -5389,7 +5389,7 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo& args) { EC_KEY_set_public_key(ecdh->key_, nullptr); MarkPopErrorOnReturn mark_pop_error_on_return; - (void) &mark_pop_error_on_return; // Silence compiler warning. + USE(&mark_pop_error_on_return); const BIGNUM* priv_key = EC_KEY_get0_private_key(ecdh->key_); CHECK_NE(priv_key, nullptr); @@ -5452,7 +5452,7 @@ bool ECDH::IsKeyValidForCurve(const BIGNUM* private_key) { bool ECDH::IsKeyPairValid() { MarkPopErrorOnReturn mark_pop_error_on_return; - (void) &mark_pop_error_on_return; // Silence compiler warning. + USE(&mark_pop_error_on_return); return 1 == EC_KEY_check_key(key_); } diff --git a/src/util.h b/src/util.h index 08308d837fbf8b..eb060a57b8801b 100644 --- a/src/util.h +++ b/src/util.h @@ -428,6 +428,9 @@ class BufferValue : public MaybeStackBuffer { if (name##_length > 0) \ CHECK_NE(name##_data, nullptr); +// Use this when a variable or parameter is unused in order to explicitly +// silence a compiler warning about that. +template inline void USE(T&&) {} } // namespace node