Skip to content

Commit 5b3e5fa

Browse files
danbevaddaleax
authored andcommitted
src: remove void casts for clear_error_on_return
There are a number of void casts of clear_error_on_return which is a usage of the RAII idiom. The ClearErrorOnReturn struct only has a destructor and no constructor which I believe was an issue in GCC prior to version 4.8.0, which lead to a unused variable warning. I'm wondering if these cast could be removed since GCC 4.8.5 or newer is required now. An alternative solution would be to add an empty constructor which should work allowing the compiler to detect that a variable is used only for its side-effects. Not sure if this was the sole reason for having these casts but wanted to bring it up just in case. Refs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10416 PR-URL: #13669 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent c27ffad commit 5b3e5fa

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

src/node_crypto.cc

-14
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ void SecureContext::AddCACert(const FunctionCallbackInfo<Value>& args) {
768768
SecureContext* sc;
769769
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());
770770
ClearErrorOnReturn clear_error_on_return;
771-
(void) &clear_error_on_return; // Silence compiler warning.
772771

773772
if (args.Length() != 1) {
774773
return env->ThrowTypeError("CA certificate argument is mandatory");
@@ -806,7 +805,6 @@ void SecureContext::AddCRL(const FunctionCallbackInfo<Value>& args) {
806805
}
807806

808807
ClearErrorOnReturn clear_error_on_return;
809-
(void) &clear_error_on_return; // Silence compiler warning.
810808

811809
BIO *bio = LoadBIO(env, args[0]);
812810
if (!bio)
@@ -872,7 +870,6 @@ void SecureContext::AddRootCerts(const FunctionCallbackInfo<Value>& args) {
872870
SecureContext* sc;
873871
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());
874872
ClearErrorOnReturn clear_error_on_return;
875-
(void) &clear_error_on_return; // Silence compiler warning.
876873

877874
if (!root_cert_store) {
878875
root_cert_store = NewRootCertStore();
@@ -901,7 +898,6 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
901898
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());
902899
Environment* env = sc->env();
903900
ClearErrorOnReturn clear_error_on_return;
904-
(void) &clear_error_on_return; // Silence compiler warning.
905901

906902
if (args.Length() != 1) {
907903
return env->ThrowTypeError("Ciphers argument is mandatory");
@@ -948,7 +944,6 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
948944
ASSIGN_OR_RETURN_UNWRAP(&sc, args.This());
949945
Environment* env = sc->env();
950946
ClearErrorOnReturn clear_error_on_return;
951-
(void) &clear_error_on_return; // Silence compiler warning.
952947

953948
// Auto DH is not supported in openssl 1.0.1, so dhparam needs
954949
// to be specified explicitly
@@ -1073,7 +1068,6 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
10731068
SecureContext* sc;
10741069
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());
10751070
ClearErrorOnReturn clear_error_on_return;
1076-
(void) &clear_error_on_return; // Silence compiler warning.
10771071

10781072
if (args.Length() < 1) {
10791073
return env->ThrowTypeError("PFX certificate argument is mandatory");
@@ -1697,7 +1691,6 @@ void SSLWrap<Base>::GetPeerCertificate(
16971691
Environment* env = w->ssl_env();
16981692

16991693
ClearErrorOnReturn clear_error_on_return;
1700-
(void) &clear_error_on_return; // Silence unused variable warning.
17011694

17021695
Local<Object> result;
17031696
Local<Object> info;
@@ -1894,7 +1887,6 @@ void SSLWrap<Base>::Renegotiate(const FunctionCallbackInfo<Value>& args) {
18941887
ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder());
18951888

18961889
ClearErrorOnReturn clear_error_on_return;
1897-
(void) &clear_error_on_return; // Silence unused variable warning.
18981890

18991891
bool yes = SSL_renegotiate(w->ssl_) == 1;
19001892
args.GetReturnValue().Set(yes);
@@ -2644,7 +2636,6 @@ int Connection::HandleSSLError(const char* func,
26442636
ZeroStatus zs,
26452637
SyscallStatus ss) {
26462638
ClearErrorOnReturn clear_error_on_return;
2647-
(void) &clear_error_on_return; // Silence unused variable warning.
26482639

26492640
if (rv > 0)
26502641
return rv;
@@ -4259,7 +4250,6 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
42594250
md_value = new unsigned char[md_len];
42604251

42614252
ClearErrorOnReturn clear_error_on_return;
4262-
(void) &clear_error_on_return; // Silence compiler warning.
42634253

42644254
Error err = sign->SignFinal(
42654255
buf,
@@ -4382,7 +4372,6 @@ SignBase::Error Verify::VerifyFinal(const char* key_pem,
43824372
return kSignNotInitialised;
43834373

43844374
ClearErrorOnReturn clear_error_on_return;
4385-
(void) &clear_error_on_return; // Silence compiler warning.
43864375

43874376
EVP_PKEY* pkey = nullptr;
43884377
BIO* bp = nullptr;
@@ -4614,7 +4603,6 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
46144603
size_t out_len = 0;
46154604

46164605
ClearErrorOnReturn clear_error_on_return;
4617-
(void) &clear_error_on_return; // Silence compiler warning.
46184606

46194607
bool r = Cipher<operation, EVP_PKEY_cipher_init, EVP_PKEY_cipher>(
46204608
kbuf,
@@ -4922,7 +4910,6 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
49224910
}
49234911

49244912
ClearErrorOnReturn clear_error_on_return;
4925-
(void) &clear_error_on_return; // Silence compiler warning.
49264913
BIGNUM* key = nullptr;
49274914

49284915
if (args.Length() == 0) {
@@ -6165,7 +6152,6 @@ void SetEngine(const FunctionCallbackInfo<Value>& args) {
61656152
unsigned int flags = args[1]->Uint32Value();
61666153

61676154
ClearErrorOnReturn clear_error_on_return;
6168-
(void) &clear_error_on_return; // Silence compiler warning.
61696155

61706156
const node::Utf8Value engine_id(env->isolate(), args[0]);
61716157
ENGINE* engine = ENGINE_by_id(*engine_id);

0 commit comments

Comments
 (0)