]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r274922:
authordim <dim@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 4 Dec 2014 01:10:50 +0000 (01:10 +0000)
committerdim <dim@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 4 Dec 2014 01:10:50 +0000 (01:10 +0000)
commit236ace6f2efd17bab34474e5a634e25d04b9a903
tree616036877e3db77b527042f5f3c31e905097b2f6
parent3f649dd4035caa368b93df73e7ef4bc46474b767
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

git-svn-id: svn://svn.freebsd.org/base/stable/10@275471 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/dev/ath/ath_hal/ar5212/ar5212_reset.c