Re: [ovs-dev] [PATCH] sat-math: Do not use __builtin_s*_overflow() with sparse.

2019-08-21 Thread Ben Pfaff
On Wed, Aug 21, 2019 at 10:20:36AM -0700, Justin Pettit wrote:
> 
> 
> > On Aug 21, 2019, at 10:17 AM, Ben Pfaff  wrote:
> > 
> > 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 
> 
> Acked-by: Justin Pettit 

Thanks, applied and backported.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] sat-math: Do not use __builtin_s*_overflow() with sparse.

2019-08-21 Thread Ben Pfaff
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