@@ -258,22 +258,29 @@ extern int daemon(int, int);
typeof(1 ? (a) : (b)) _a = (a), _b = (b); \
_a < _b ? _a : _b; \
})
-#define MIN_CONST(a, b) \
- __builtin_choose_expr( \
- __builtin_constant_p(a) && __builtin_constant_p(b), \
- (a) < (b) ? (a) : (b), \
- ((void)0))
+
#undef MAX
#define MAX(a, b) \
({ \
typeof(1 ? (a) : (b)) _a = (a), _b = (b); \
_a > _b ? _a : _b; \
})
+
+#ifdef __COVERITY__
+#define MIN_CONST(a, b) (a) < (b) ? (a) : (b)
+#define MAX_CONST(a, b) (a) > (b) ? (a) : (b)
+#else
+#define MIN_CONST(a, b) \
+ __builtin_choose_expr( \
+ __builtin_constant_p(a) && __builtin_constant_p(b), \
+ (a) < (b) ? (a) : (b), \
+ ((void)0))
#define MAX_CONST(a, b) \
__builtin_choose_expr( \
__builtin_constant_p(a) && __builtin_constant_p(b), \
(a) > (b) ? (a) : (b), \
((void)0))
+#endif
/*
* Minimum function that returns zero only if both values are zero.
Coverity's parser chokes on __builtin_choose_expr inside a constant expression. Since it is used only to raise compilation errors for non-constant arguments, we can just assume there are no such errors in the Coverity runs, and define MIN_CONST and MAX_CONST to the "classic" ternary-operator-based definitions of minimum and maximum. Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- include/qemu/osdep.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)