diff src/evalfunc.c @ 27752:c1d1639b52dd v8.2.4402

patch 8.2.4402: missing parenthesis may cause unexpected problems Commit: https://github.com/vim/vim/commit/ae6f1d8b14c2f63811ee83ef14e32086fb3e9b83 Author: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Wed Feb 16 19:24:07 2022 +0000 patch 8.2.4402: missing parenthesis may cause unexpected problems Problem: Missing parenthesis may cause unexpected problems. Solution: Add more parenthesis is macros. (closes https://github.com/vim/vim/issues/9788)
author Bram Moolenaar <Bram@vim.org>
date Wed, 16 Feb 2022 20:30:03 +0100
parents 3813036f19cb
children 324d394e314e
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -7878,21 +7878,21 @@ init_srand(UINT32_T *x)
 	*x = vim_time();
 }
 
-#define ROTL(x, k) ((x << k) | (x >> (32 - k)))
+#define ROTL(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
 #define SPLITMIX32(x, z) ( \
-    z = (x += 0x9e3779b9), \
-    z = (z ^ (z >> 16)) * 0x85ebca6b, \
-    z = (z ^ (z >> 13)) * 0xc2b2ae35, \
-    z ^ (z >> 16) \
+    (z) = ((x) += 0x9e3779b9), \
+    (z) = ((z) ^ ((z) >> 16)) * 0x85ebca6b, \
+    (z) = ((z) ^ ((z) >> 13)) * 0xc2b2ae35, \
+    (z) ^ ((z) >> 16) \
     )
 #define SHUFFLE_XOSHIRO128STARSTAR(x, y, z, w) \
-    result = ROTL(y * 5, 7) * 9; \
-    t = y << 9; \
-    z ^= x; \
-    w ^= y; \
-    y ^= z, x ^= w; \
-    z ^= t; \
-    w = ROTL(w, 11);
+    result = ROTL((y) * 5, 7) * 9; \
+    t = (y) << 9; \
+    (z) ^= (x); \
+    (w) ^= (y); \
+    (y) ^= (z), (x) ^= (w); \
+    (z) ^= t; \
+    (w) = ROTL(w, 11);
 
 /*
  * "rand()" function