diff options
author | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-08-18 20:29:35 +0300 |
---|---|---|
committer | Kevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com> | 2020-09-01 09:37:03 +0300 |
commit | 5cec1373ad6d28845a9588033171cd65dc29fc1e (patch) | |
tree | 4189aa99dc2aabea1b534d3cfc2e010bd5242740 | |
parent | 608bf025e6f6bd34266a47b0c92273dd8fbccba9 (diff) |
Enable bugprone-macro-parentheses clang-tidy check
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | src/common/c_jhash.h | 42 | ||||
-rw-r--r-- | src/csync/csync_macros.h | 10 | ||||
-rw-r--r-- | src/csync/std/c_macro.h | 4 |
4 files changed, 29 insertions, 28 deletions
diff --git a/.clang-tidy b/.clang-tidy index b877c6d0a..d8b14cd39 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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, diff --git a/src/common/c_jhash.h b/src/common/c_jhash.h index bd5e9d754..1b6c2fcdf 100644 --- a/src/common/c_jhash.h +++ b/src/common/c_jhash.h @@ -57,15 +57,15 @@ */ #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); \ } /** @@ -88,18 +88,18 @@ */ #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); \ } /** diff --git a/src/csync/csync_macros.h b/src/csync/csync_macros.h index 0f505ec42..492bc6bfa 100644 --- a/src/csync/csync_macros.h +++ b/src/csync/csync_macros.h @@ -26,16 +26,16 @@ #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: */ diff --git a/src/csync/std/c_macro.h b/src/csync/std/c_macro.h index e65c2c780..6e9cafb08 100644 --- a/src/csync/std/c_macro.h +++ b/src/csync/std/c_macro.h @@ -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 |