From patchwork Wed Aug 21 17:17:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1150990 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46DDr21mcGz9sDQ for ; Thu, 22 Aug 2019 03:17:37 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6B330CBA; Wed, 21 Aug 2019 17:17:34 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 07461CB0 for ; Wed, 21 Aug 2019 17:17:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 54A538A0 for ; Wed, 21 Aug 2019 17:17:32 +0000 (UTC) X-Originating-IP: 75.54.222.30 Received: from sigurg.attlocal.net (75-54-222-30.lightspeed.rdcyca.sbcglobal.net [75.54.222.30]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 632611C0007; Wed, 21 Aug 2019 17:17:27 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 21 Aug 2019 10:17:21 -0700 Message-Id: <20190821171721.20048-1-blp@ovn.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH] sat-math: Do not use __builtin_s*_overflow() with sparse. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- 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) ? 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) ? 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) ? product : (x > 0) == (y > 0) ? LLONG_MAX : LLONG_MIN);