aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/sha256.c
diff options
context:
space:
mode:
authorBrian Leung <leungbk@posteo.net>2022-04-03 02:36:01 -0700
committerBrian Leung <leungbk@posteo.net>2022-04-03 16:11:23 -0700
commit69e11b58b4db0952f11a5ff85aa7150b5f5b8db8 (patch)
tree2c10f1348a50480eacf10a003c49e6f16a5f8049 /src/nvim/sha256.c
parent271bb32855853b011fceaf0ad2f829bce66b2a19 (diff)
downloadrneovim-69e11b58b4db0952f11a5ff85aa7150b5f5b8db8.tar.gz
rneovim-69e11b58b4db0952f11a5ff85aa7150b5f5b8db8.tar.bz2
rneovim-69e11b58b4db0952f11a5ff85aa7150b5f5b8db8.zip
vim-patch:8.2.4402: missing parenthesis may cause unexpected problems
Problem: Missing parenthesis may cause unexpected problems. Solution: Add more parenthesis is macros. https://github.com/vim/vim/commit/ae6f1d8b14c2f63811ee83ef14e32086fb3e9b83
Diffstat (limited to 'src/nvim/sha256.c')
-rw-r--r--src/nvim/sha256.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/nvim/sha256.c b/src/nvim/sha256.c
index 9d6a2f2c41..2c6199bf8b 100644
--- a/src/nvim/sha256.c
+++ b/src/nvim/sha256.c
@@ -73,8 +73,8 @@ static void sha256_process(context_sha256_T *ctx, const char_u data[SHA256_BUFFE
GET_UINT32(W[14], data, 56);
GET_UINT32(W[15], data, 60);
-#define SHR(x, n) ((x & 0xFFFFFFFF) >> n)
-#define ROTR(x, n) (SHR(x, n) | (x << (32 - n)))
+#define SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
+#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
#define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
#define S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
@@ -82,17 +82,16 @@ static void sha256_process(context_sha256_T *ctx, const char_u data[SHA256_BUFFE
#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
-#define F0(x, y, z) ((x & y) | (z & (x | y)))
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
+#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define R(t) \
- (W[t] = S1(W[t - 2]) + W[t - 7] + \
- S0(W[t - 15]) + W[t - 16])
+ (W[t] = S1(W[(t) - 2]) + W[(t) - 7] + S0(W[(t) - 15]) + W[(t) - 16])
#define P(a, b, c, d, e, f, g, h, x, K) { \
- temp1 = h + S3(e) + F1(e, f, g) + K + x; \
+ temp1 = (h) + S3(e) + F1(e, f, g) + (K) + (x); \
temp2 = S2(a) + F0(a, b, c); \
- d += temp1; h = temp1 + temp2; \
+ (d) += temp1; (h) = temp1 + temp2; \
}
A = ctx->state[0];