Enable bugprone-macro-parentheses clang-tidy check
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 18 Aug 2020 17:29:35 +0000 (19:29 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Tue, 1 Sep 2020 06:37:03 +0000 (06:37 +0000)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
.clang-tidy
src/common/c_jhash.h
src/csync/csync_macros.h
src/csync/std/c_macro.h

index b877c6d0a6c1c2e0f860084d1ba30e4451cef0c7..d8b14cd391896f28768d63336cf491937be802c8 100644 (file)
@@ -2,6 +2,7 @@ Checks: '-*,
     bugprone-argument-comment,
     bugprone-branch-clone,
     bugprone-forward-declaration-namespace,
+    bugprone-macro-parentheses,
     cppcoreguidelines-init-variables,
     misc-*,
     -misc-non-private-member-variables-in-classes,
index bd5e9d754526049b0b54c167abe93510781c0ef7..1b6c2fcdf5838c122ebc1cdd5d6dbb1bda2d2196 100644 (file)
  */
 #define _c_mix(a,b,c) \
 { \
-  a -= b; a -= c; a ^= (c>>13); \
-  b -= c; b -= a; b ^= (a<<8); \
-  c -= a; c -= b; c ^= (b>>13); \
-  a -= b; a -= c; a ^= (c>>12);  \
-  b -= c; b -= a; b ^= (a<<16); \
-  c -= a; c -= b; c ^= (b>>5); \
-  a -= b; a -= c; a ^= (c>>3);  \
-  b -= c; b -= a; b ^= (a<<10); \
-  c -= a; c -= b; c ^= (b>>15); \
+  (a) -= (b); (a) -= (c); (a) ^= ((c)>>13); \
+  (b) -= (c); (b) -= (a); (b) ^= ((a)<<8); \
+  (c) -= (a); (c) -= (b); (c) ^= ((b)>>13); \
+  (a) -= (b); (a) -= (c); (a) ^= ((c)>>12);  \
+  (b) -= (c); (b) -= (a); (b) ^= ((a)<<16); \
+  (c) -= (a); (c) -= (b); (c) ^= ((b)>>5); \
+  (a) -= (b); (a) -= (c); (a) ^= ((c)>>3);  \
+  (b) -= (c); (b) -= (a); (b) ^= ((a)<<10); \
+  (c) -= (a); (c) -= (b); (c) ^= ((b)>>15); \
 }
 
 /**
  */
 #define _c_mix64(a,b,c) \
 { \
-  a -= b; a -= c; a ^= (c>>43); \
-  b -= c; b -= a; b ^= (a<<9); \
-  c -= a; c -= b; c ^= (b>>8); \
-  a -= b; a -= c; a ^= (c>>38); \
-  b -= c; b -= a; b ^= (a<<23); \
-  c -= a; c -= b; c ^= (b>>5); \
-  a -= b; a -= c; a ^= (c>>35); \
-  b -= c; b -= a; b ^= (a<<49); \
-  c -= a; c -= b; c ^= (b>>11); \
-  a -= b; a -= c; a ^= (c>>12); \
-  b -= c; b -= a; b ^= (a<<18); \
-  c -= a; c -= b; c ^= (b>>22); \
+  (a) -= (b); (a) -= (c); (a) ^= ((c)>>43); \
+  (b) -= (c); (b) -= (a); (b) ^= ((a)<<9); \
+  (c) -= (a); (c) -= (b); (c) ^= ((b)>>8); \
+  (a) -= (b); (a) -= (c); (a) ^= ((c)>>38); \
+  (b) -= (c); (b) -= (a); (b) ^= ((a)<<23); \
+  (c) -= (a); (c) -= (b); (c) ^= ((b)>>5); \
+  (a) -= (b); (a) -= (c); (a) ^= ((c)>>35); \
+  (b) -= (c); (b) -= (a); (b) ^= ((a)<<49); \
+  (c) -= (a); (c) -= (b); (c) ^= ((b)>>11); \
+  (a) -= (b); (a) -= (c); (a) ^= ((c)>>12); \
+  (b) -= (c); (b) -= (a); (b) ^= ((a)<<18); \
+  (c) -= (a); (c) -= (b); (c) ^= ((b)>>22); \
 }
 
 /**
index 0f505ec42db874b9887213bba0978eae33b7467a..492bc6bfaaa4120ace50844d3186f35940fd7679 100644 (file)
 #include <cstring>
 
 /* How many elements there are in a static array */
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
 
 /* Some special custom errno values to report bugs properly. The BASE value
  * should always be larger than the highest system errno. */
 #define CSYNC_CUSTOM_ERRNO_BASE 10000
 
-#define ERRNO_WRONG_CONTENT          CSYNC_CUSTOM_ERRNO_BASE+11
-#define ERRNO_SERVICE_UNAVAILABLE    CSYNC_CUSTOM_ERRNO_BASE+14
-#define ERRNO_STORAGE_UNAVAILABLE    CSYNC_CUSTOM_ERRNO_BASE+17
-#define ERRNO_FORBIDDEN              CSYNC_CUSTOM_ERRNO_BASE+18
+#define ERRNO_WRONG_CONTENT          (CSYNC_CUSTOM_ERRNO_BASE+11)
+#define ERRNO_SERVICE_UNAVAILABLE    (CSYNC_CUSTOM_ERRNO_BASE+14)
+#define ERRNO_STORAGE_UNAVAILABLE    (CSYNC_CUSTOM_ERRNO_BASE+17)
+#define ERRNO_FORBIDDEN              (CSYNC_CUSTOM_ERRNO_BASE+18)
 
 #endif /* _CSYNC_MACROS_H */
 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
index e65c2c78096064a288e1dc2d56a4a25b29a36eb4..6e9cafb0802144261292ff1bc5b81a439af68cd4 100644 (file)
@@ -44,7 +44,7 @@
 #define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
 
 /** Free memory and zero the pointer */
-#define SAFE_FREE(x) do { if ((x) != NULL) {free((void*)x); x=NULL;} } while(0)
+#define SAFE_FREE(x) do { if ((x) != NULL) {free((void*)(x)); (x)=NULL;} } while(0)
 
 /** Get the smaller value */
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -53,7 +53,7 @@
 #define MAX(a,b) ((a) < (b) ? (b) : (a))
 
 /** Get the size of an array */
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
 
 /**
  * This is a hack to fix warnings. The idea is to use this everywhere that we