Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
src: introduce USE() for silencing compiler warnings
  • Loading branch information
addaleax committed Nov 27, 2017
commit 64acf5499b27cdd211c5f2627f5f8255d81cc0a9
12 changes: 4 additions & 8 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ void AsyncWrap::EmitPromiseResolve(Environment* env, double async_id) {
Local<Value> async_id_value = Number::New(env->isolate(), async_id);
Local<Function> fn = env->async_hooks_promise_resolve_function();
FatalTryCatch try_catch(env);
fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)
.FromMaybe(Local<Value>());
USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));
}


Expand Down Expand Up @@ -198,8 +197,7 @@ void AsyncWrap::EmitBefore(Environment* env, double async_id) {
Local<Value> async_id_value = Number::New(env->isolate(), async_id);
Local<Function> fn = env->async_hooks_before_function();
FatalTryCatch try_catch(env);
fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)
.FromMaybe(Local<Value>());
USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));
}


Expand Down Expand Up @@ -229,8 +227,7 @@ void AsyncWrap::EmitAfter(Environment* env, double async_id) {
Local<Value> async_id_value = Number::New(env->isolate(), async_id);
Local<Function> fn = env->async_hooks_after_function();
FatalTryCatch try_catch(env);
fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)
.FromMaybe(Local<Value>());
USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));
}

class PromiseWrap : public AsyncWrap {
Expand Down Expand Up @@ -731,8 +728,7 @@ void AsyncWrap::EmitAsyncInit(Environment* env,
};

FatalTryCatch try_catch(env);
init_fn->Call(env->context(), object, arraysize(argv), argv)
.FromMaybe(Local<Value>());
USE(init_fn->Call(env->context(), object, arraysize(argv), argv));
}


Expand Down
18 changes: 9 additions & 9 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ static Local<Object> 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) {
Expand All @@ -1829,7 +1829,7 @@ static Local<Object> 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<String> keys[] = { env->subjectaltname_string(),
Expand All @@ -1856,7 +1856,7 @@ static Local<Object> 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);
Expand All @@ -1873,7 +1873,7 @@ static Local<Object> 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<uint64_t>(BN_get_word(e));
uint32_t lo = static_cast<uint32_t>(exponent_word);
Expand All @@ -1887,7 +1887,7 @@ static Local<Object> 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) {
Expand All @@ -1904,7 +1904,7 @@ static Local<Object> 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);
Expand Down Expand Up @@ -2882,7 +2882,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",
Expand Down Expand Up @@ -5358,7 +5358,7 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& 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); // Silence compiler warning.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move this comment to where USE() is defined.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, done.


const BIGNUM* priv_key = EC_KEY_get0_private_key(ecdh->key_);
CHECK_NE(priv_key, nullptr);
Expand Down Expand Up @@ -5421,7 +5421,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); // Silence compiler warning.
return 1 == EC_KEY_check_key(key_);
}

Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ class BufferValue : public MaybeStackBuffer<char> {
if (name##_length > 0) \
CHECK_NE(name##_data, nullptr);

template <typename T> inline void USE(T&&) {}

} // namespace node

Expand Down