Skip to content

Commit 15fd0d9

Browse files
danbevaddaleax
authored andcommitted
src: fix node_crypto.cc compiler warnings
Currently the following compiler warnings are issued by clang: ../src/node_crypto.cc:2801:56: warning: '&&' within '||' [-Wlogical-op-parentheses] return tag_len == 4 || tag_len == 8 || tag_len >= 12 && tag_len <= 16; ~~ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ ../src/node_crypto.cc:2801:56: note: place parentheses around the '&&' expression to silence this warning return tag_len == 4 || tag_len == 8 || tag_len >= 12 && tag_len <= 16; ^ ../src/node_crypto.cc:2925:51: warning: '&&' within '||' [-Wlogical-op-parentheses] if (cipher->auth_tag_len_ != kNoAuthTagLength && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ ../src/node_crypto.cc:2925:51: note: place parentheses around the '&&' expression to silence this warning if (cipher->auth_tag_len_ != kNoAuthTagLength && ^ This commit adds parenthesis around these expressions to silence the warnings. PR-URL: #20216 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c07c73c commit 15fd0d9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/node_crypto.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ void CipherBase::InitIv(const FunctionCallbackInfo<Value>& args) {
27982798

27992799

28002800
static bool IsValidGCMTagLength(unsigned int tag_len) {
2801-
return tag_len == 4 || tag_len == 8 || tag_len >= 12 && tag_len <= 16;
2801+
return tag_len == 4 || tag_len == 8 || (tag_len >= 12 && tag_len <= 16);
28022802
}
28032803

28042804
bool CipherBase::InitAuthenticated(const char *cipher_type, int iv_len,
@@ -2922,8 +2922,8 @@ void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) {
29222922
unsigned int tag_len = Buffer::Length(args[0]);
29232923
const int mode = EVP_CIPHER_CTX_mode(cipher->ctx_);
29242924
if (mode == EVP_CIPH_GCM_MODE) {
2925-
if (cipher->auth_tag_len_ != kNoAuthTagLength &&
2926-
cipher->auth_tag_len_ != tag_len ||
2925+
if ((cipher->auth_tag_len_ != kNoAuthTagLength &&
2926+
cipher->auth_tag_len_ != tag_len) ||
29272927
!IsValidGCMTagLength(tag_len)) {
29282928
char msg[50];
29292929
snprintf(msg, sizeof(msg),

0 commit comments

Comments
 (0)