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)
Sun, Apr 21, 1:10 PM
Unknown Object (File)
Mar 25 2024, 10:27 PM
Unknown Object (File)
Mar 8 2024, 11:45 PM
Unknown Object (File)
Mar 2 2024, 4:36 PM
Unknown Object (File)
Jan 22 2024, 7:46 AM
Unknown Object (File)
Jan 1 2024, 5:06 AM
Unknown Object (File)
Dec 19 2023, 11:48 PM
Unknown Object (File)
Dec 16 2023, 10:01 AM
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).