]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix the following -Werror warning from clang 3.5.0, while building the
authorDimitry Andric <dim@FreeBSD.org>
Sun, 23 Nov 2014 18:31:55 +0000 (18:31 +0000)
committerDimitry Andric <dim@FreeBSD.org>
Sun, 23 Nov 2014 18:31:55 +0000 (18:31 +0000)
commitd41b89cca5f26bbafb496a93c4a48cdf282833ee
tree631dd25608c1be79f72ea2c61385d60a3be32456
parent26ec34919932ae7c7b5daa7700e5ea901095d413
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
sys/dev/ath/ath_hal/ar5212/ar5212_reset.c