From owner-svn-src-head@FreeBSD.ORG Sun Nov 23 18:31:56 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9484EC4B; Sun, 23 Nov 2014 18:31:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 66D7A63B; Sun, 23 Nov 2014 18:31:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sANIVuXR011565; Sun, 23 Nov 2014 18:31:56 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sANIVuMX011564; Sun, 23 Nov 2014 18:31:56 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201411231831.sANIVuMX011564@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 23 Nov 2014 18:31:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274922 - head/sys/dev/ath/ath_hal/ar5212 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Nov 2014 18:31:56 -0000 Author: dim Date: Sun Nov 23 18:31:55 2014 New Revision: 274922 URL: https://svnweb.freebsd.org/changeset/base/274922 Log: Fix the following -Werror warning from clang 3.5.0, while building the ath kernel module: sys/dev/ath/ath_hal/ar5212/ar5212_reset.c:2642:7: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value] if (abs(lp[0] * EEP_SCALE - target) < EEP_DELTA) { ^ sys/dev/ath/ah_osdep.h:74:18: note: expanded from macro 'abs' #define abs(_a) __builtin_abs(_a) ^ sys/dev/ath/ath_hal/ar5212/ar5212_reset.c:2642:7: note: remove the call to '__builtin_abs' since unsigned values cannot be negative sys/dev/ath/ah_osdep.h:74:18: note: expanded from macro 'abs' #define abs(_a) __builtin_abs(_a) ^ 1 error generated. This warning occurs because both lp[0] and target are unsigned, so the subtraction expression is also unsigned, and calling abs() is a no-op. However, the intention was to look at the absolute difference between the two unsigned quantities. Introduce a small static function to clarify what we're doing, and call that instead. Reviewed by: adrian MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D1212 Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Sun Nov 23 17:47:12 2014 (r274921) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Sun Nov 23 18:31:55 2014 (r274922) @@ -2605,6 +2605,12 @@ ar5212GetTargetPowers(struct ath_hal *ah powInfo[ixlo].twicePwr54, powInfo[ixhi].twicePwr54); } +static uint32_t +udiff(uint32_t u, uint32_t v) +{ + return (u >= v ? u - v : v - u); +} + /* * Search a list for a specified value v that is within * EEP_DELTA of the search values. Return the closest @@ -2639,7 +2645,7 @@ ar5212GetLowerUpperValues(uint16_t v, ui * If value is close to the current value of the list * then target is not between values, it is one of the values */ - if (abs(lp[0] * EEP_SCALE - target) < EEP_DELTA) { + if (udiff(lp[0] * EEP_SCALE, target) < EEP_DELTA) { *vlo = *vhi = lp[0]; return; }