summaryrefslogtreecommitdiff
path: root/src/basic/macro.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-01-04 09:45:23 +0100
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:49:50 +0200
commit2ad82ee806c84cb54f43878c3f6124dde4ef6f8f (patch)
treed9e6ab5a4507bd4da003bdcf67749b94c4519908 /src/basic/macro.h
parentd35de6b354067139d1aa398d19a5d35a25fd1d03 (diff)
coverity: don't use (void)0 under coverity
I'm not sure why this is needed, but apparrently coverity doesn't like (void)0. With this change, coverity can (almost) build systemd: CFLAGS='-D_Float128="long double"' meson cov-build -Dman=false && \ CCACHE_DISABLE=1 COVERITY_UNSUPPORTED=1 cov-build --dir cov-int ninja -C cov-build Patch originially by Marek Cermak <macermak@redhat.com>.
Diffstat (limited to 'src/basic/macro.h')
-rw-r--r--src/basic/macro.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/basic/macro.h b/src/basic/macro.h
index 02d22de83..89bdd852a 100644
--- a/src/basic/macro.h
+++ b/src/basic/macro.h
@@ -139,11 +139,17 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
return 1UL << (sizeof(u) * 8 - __builtin_clzl(u - 1UL));
}
+#ifndef __COVERITY__
+# define VOID_0 ((void)0)
+#else
+# define VOID_0 ((void*)0)
+#endif
+
#define ELEMENTSOF(x) \
__extension__ (__builtin_choose_expr( \
!__builtin_types_compatible_p(typeof(x), typeof(&*(x))), \
sizeof(x)/sizeof((x)[0]), \
- (void)0))
+ VOID_0))
/*
* STRLEN - return the length of a string literal, minus the trailing NUL byte.
@@ -181,7 +187,7 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
__builtin_constant_p(_B) && \
__builtin_types_compatible_p(typeof(_A), typeof(_B)), \
((_A) > (_B)) ? (_A) : (_B), \
- (void)0))
+ VOID_0))
/* takes two types and returns the size of the larger one */
#define MAXSIZE(A, B) (sizeof(union _packed_ { typeof(A) a; typeof(B) b; }))