]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: macros - Add ENUM_NEGATE
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 11 Aug 2020 05:41:54 +0000 (08:41 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 22 Oct 2020 12:16:16 +0000 (12:16 +0000)
Handles enumeration flag negation.

src/lib/macros.h

index 6a3c7f45b156d09941903b1b06ab5b582f4c0d49..7e67a4d16d271e19fc9935300eef1c699f74267b 100644 (file)
 # define ATTR_NO_SANITIZE_INTEGER
 # define ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 #endif
+
+/* negate enumeration flags in a way that avoids implicit conversion */
+#define ENUM_NEGATE(x) \
+       ((unsigned int)(~(x)) + COMPILE_ERROR_IF_TRUE(sizeof((x)) > sizeof(int) || (x) < 0 || (x) > INT_MAX))