Some versions of sparse do not understand __builtin_saddll_overflow() and
related GCC builtins for calculations with overflow detection. This patch
avoids using them when sparse is in use.
Reported-by: Justin Pettit
Tested-by: Justin Pettit
Signed-off-by: Ben Pfaff
---
lib/sat-math.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/sat-math.h b/lib/sat-math.h
index 8dda1515fdd0..d668723878db 100644
--- a/lib/sat-math.h
+++ b/lib/sat-math.h
@@ -41,7 +41,7 @@ llsat_add__(long long int x, long long int y)
static inline long long int
llsat_add(long long int x, long long int y)
{
-#if __GNUC__ >= 5 || __has_builtin(__builtin_saddll_overflow)
+#if (__GNUC__ >= 5 || __has_builtin(__builtin_saddll_overflow)) && !__CHECKER__
long long int sum;
return (!__builtin_saddll_overflow(x, y, ) ? sum
: x > 0 ? LLONG_MAX : LLONG_MIN);
@@ -67,7 +67,7 @@ llsat_sub__(long long int x, long long int y)
static inline long long int
llsat_sub(long long int x, long long int y)
{
-#if __GNUC__ >= 5 || __has_builtin(__builtin_ssubll_overflow)
+#if (__GNUC__ >= 5 || __has_builtin(__builtin_ssubll_overflow)) && !__CHECKER__
long long int difference;
return (!__builtin_ssubll_overflow(x, y, ) ? difference
: x >= 0 ? LLONG_MAX : LLONG_MIN);
@@ -97,7 +97,7 @@ llsat_mul__(long long int x, long long int y)
static inline long long int
llsat_mul(long long int x, long long int y)
{
-#if __GNUC__ >= 5 || __has_builtin(__builtin_smulll_overflow)
+#if (__GNUC__ >= 5 || __has_builtin(__builtin_smulll_overflow)) && !__CHECKER__
long long int product;
return (!__builtin_smulll_overflow(x, y, ) ? product
: (x > 0) == (y > 0) ? LLONG_MAX : LLONG_MIN);
--
2.20.1
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev