Page MenuHomeFreeBSD

Fix clang 3.5.0 warning in ath's ar5212_reset.c
ClosedPublic

Authored by dim on Nov 23 2014, 12:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 5, 1:56 AM
Unknown Object (File)
Sat, Oct 26, 8:44 AM
Unknown Object (File)
Sat, Oct 26, 8:44 AM
Unknown Object (File)
Sat, Oct 26, 8:44 AM
Unknown Object (File)
Sat, Oct 26, 8:32 AM
Unknown Object (File)
Oct 1 2024, 9:31 PM
Unknown Object (File)
Oct 1 2024, 9:30 PM
Unknown Object (File)
Oct 1 2024, 8:21 PM
Subscribers
None

Details

Summary

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 probably 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.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dim retitled this revision from to Fix clang 3.5.0 warning in ath's ar5212_reset.c.
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added reviewers: adrian, emaste.
adrian edited edge metadata.

yup, looks fine.

This revision is now accepted and ready to land.Nov 23 2014, 4:44 PM
dim updated this revision to Diff 2515.

Closed by commit rS274922 (authored by @dim).