From: Timo Sirainen Date: Fri, 10 Sep 2021 16:00:09 +0000 (+0300) Subject: lib: ENUM_NEGATE() - Disable runtime sizeof() check with STATIC_CHECKER X-Git-Tag: 2.3.17~132 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da3bc6ea23e8fb76def22aebca8cfb65042683dc;p=thirdparty%2Fdovecot%2Fcore.git lib: ENUM_NEGATE() - Disable runtime sizeof() check with STATIC_CHECKER This is to avoid "Dangerous variable-length array (VLA) declaration" errors with clang 12 scan-build, which happen because scan-build keeps thinking that the enums can become larger than 2147483647. --- diff --git a/src/lib/macros.h b/src/lib/macros.h index c264ec6066..d41570a282 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -298,5 +298,11 @@ #endif /* negate enumeration flags in a way that avoids implicit conversion */ -#define ENUM_NEGATE(x) \ +#ifndef STATIC_CHECKER +# define ENUM_NEGATE(x) \ ((unsigned int)(~(x)) + COMPILE_ERROR_IF_TRUE(sizeof((x)) > sizeof(int) || (x) < 0 || (x) > INT_MAX)) +#else +/* clang scan-build keeps complaining about x > 2147483647 case, so disable the + sizeof check. */ +# define ENUM_NEGATE(x) ((unsigned int)(~(x))) +#endif