Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9b27bc8

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
src: introduce USE() for silencing compiler warnings
PR-URL: #17333 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent bd79c37 commit 9b27bc8
Copy full SHA for 9b27bc8

File tree

Expand file treeCollapse file tree

3 files changed

+16
-17
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-17
lines changed
Open diff view settings
Collapse file

‎src/async_wrap.cc‎

Copy file name to clipboardExpand all lines: src/async_wrap.cc
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ void AsyncWrap::EmitPromiseResolve(Environment* env, double async_id) {
173173
Local<Value> async_id_value = Number::New(env->isolate(), async_id);
174174
Local<Function> fn = env->async_hooks_promise_resolve_function();
175175
FatalTryCatch try_catch(env);
176-
fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)
177-
.FromMaybe(Local<Value>());
176+
USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));
178177
}
179178

180179

@@ -202,8 +201,7 @@ void AsyncWrap::EmitBefore(Environment* env, double async_id) {
202201
Local<Value> async_id_value = Number::New(env->isolate(), async_id);
203202
Local<Function> fn = env->async_hooks_before_function();
204203
FatalTryCatch try_catch(env);
205-
fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)
206-
.FromMaybe(Local<Value>());
204+
USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));
207205
}
208206

209207

@@ -233,8 +231,7 @@ void AsyncWrap::EmitAfter(Environment* env, double async_id) {
233231
Local<Value> async_id_value = Number::New(env->isolate(), async_id);
234232
Local<Function> fn = env->async_hooks_after_function();
235233
FatalTryCatch try_catch(env);
236-
fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)
237-
.FromMaybe(Local<Value>());
234+
USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));
238235
}
239236

240237
class PromiseWrap : public AsyncWrap {
@@ -736,8 +733,7 @@ void AsyncWrap::EmitAsyncInit(Environment* env,
736733
};
737734

738735
FatalTryCatch try_catch(env);
739-
init_fn->Call(env->context(), object, arraysize(argv), argv)
740-
.FromMaybe(Local<Value>());
736+
USE(init_fn->Call(env->context(), object, arraysize(argv), argv));
741737
}
742738

743739

Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
18271827
String::NewFromUtf8(env->isolate(), mem->data,
18281828
String::kNormalString, mem->length));
18291829
}
1830-
(void) BIO_reset(bio);
1830+
USE(BIO_reset(bio));
18311831

18321832
X509_NAME* issuer_name = X509_get_issuer_name(cert);
18331833
if (X509_NAME_print_ex(bio, issuer_name, 0, X509_NAME_FLAGS) > 0) {
@@ -1836,7 +1836,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
18361836
String::NewFromUtf8(env->isolate(), mem->data,
18371837
String::kNormalString, mem->length));
18381838
}
1839-
(void) BIO_reset(bio);
1839+
USE(BIO_reset(bio));
18401840

18411841
int nids[] = { NID_subject_alt_name, NID_info_access };
18421842
Local<String> keys[] = { env->subjectaltname_string(),
@@ -1863,7 +1863,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
18631863
String::NewFromUtf8(env->isolate(), mem->data,
18641864
String::kNormalString, mem->length));
18651865

1866-
(void) BIO_reset(bio);
1866+
USE(BIO_reset(bio));
18671867
}
18681868

18691869
EVP_PKEY* pkey = X509_get_pubkey(cert);
@@ -1880,7 +1880,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
18801880
info->Set(env->modulus_string(),
18811881
String::NewFromUtf8(env->isolate(), mem->data,
18821882
String::kNormalString, mem->length));
1883-
(void) BIO_reset(bio);
1883+
USE(BIO_reset(bio));
18841884

18851885
uint64_t exponent_word = static_cast<uint64_t>(BN_get_word(e));
18861886
uint32_t lo = static_cast<uint32_t>(exponent_word);
@@ -1894,7 +1894,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
18941894
info->Set(env->exponent_string(),
18951895
String::NewFromUtf8(env->isolate(), mem->data,
18961896
String::kNormalString, mem->length));
1897-
(void) BIO_reset(bio);
1897+
USE(BIO_reset(bio));
18981898
}
18991899

19001900
if (pkey != nullptr) {
@@ -1911,7 +1911,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
19111911
info->Set(env->valid_from_string(),
19121912
String::NewFromUtf8(env->isolate(), mem->data,
19131913
String::kNormalString, mem->length));
1914-
(void) BIO_reset(bio);
1914+
USE(BIO_reset(bio));
19151915

19161916
ASN1_TIME_print(bio, X509_get_notAfter(cert));
19171917
BIO_get_mem_ptr(bio, &mem);
@@ -2889,7 +2889,7 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) {
28892889
return rv;
28902890

28912891
int retry = BIO_should_retry(bio);
2892-
(void) retry; // unused if !defined(SSL_PRINT_DEBUG)
2892+
USE(retry); // unused if !defined(SSL_PRINT_DEBUG)
28932893

28942894
if (BIO_should_write(bio)) {
28952895
DEBUG_PRINT("[%p] BIO: %s want write. should retry %d\n",
@@ -5389,7 +5389,7 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
53895389
EC_KEY_set_public_key(ecdh->key_, nullptr);
53905390

53915391
MarkPopErrorOnReturn mark_pop_error_on_return;
5392-
(void) &mark_pop_error_on_return; // Silence compiler warning.
5392+
USE(&mark_pop_error_on_return);
53935393

53945394
const BIGNUM* priv_key = EC_KEY_get0_private_key(ecdh->key_);
53955395
CHECK_NE(priv_key, nullptr);
@@ -5452,7 +5452,7 @@ bool ECDH::IsKeyValidForCurve(const BIGNUM* private_key) {
54525452

54535453
bool ECDH::IsKeyPairValid() {
54545454
MarkPopErrorOnReturn mark_pop_error_on_return;
5455-
(void) &mark_pop_error_on_return; // Silence compiler warning.
5455+
USE(&mark_pop_error_on_return);
54565456
return 1 == EC_KEY_check_key(key_);
54575457
}
54585458

Collapse file

‎src/util.h‎

Copy file name to clipboardExpand all lines: src/util.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ class BufferValue : public MaybeStackBuffer<char> {
428428
if (name##_length > 0) \
429429
CHECK_NE(name##_data, nullptr);
430430

431+
// Use this when a variable or parameter is unused in order to explicitly
432+
// silence a compiler warning about that.
433+
template <typename T> inline void USE(T&&) {}
431434

432435
} // namespace node
433436

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.