Author: dim
Date: Thu Dec  4 01:10:50 2014
New Revision: 275471
URL: https://svnweb.freebsd.org/changeset/base/275471

Log:
  MFC r274922:
  
  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
  Differential Revision: https://reviews.freebsd.org/D1212

Modified:
  stable/9/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c
Directory Properties:
  stable/9/sys/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/9/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c
==============================================================================
--- stable/9/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c  Wed Dec  3 23:37:23 
2014        (r275470)
+++ stable/9/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c  Thu Dec  4 01:10:50 
2014        (r275471)
@@ -2459,6 +2459,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
@@ -2493,7 +2499,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;
                }
_______________________________________________
svn-src-stable-9@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"

Reply via email to