]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/commit
MFC r274898:
authordim <dim@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 25 Nov 2014 13:12:45 +0000 (13:12 +0000)
committerdim <dim@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 25 Nov 2014 13:12:45 +0000 (13:12 +0000)
commit977e1b9e3539e7f60da43062c5e46131b40d0bc6
tree439c2e7641ea0dbd6dc7fb07289b7747827bc65d
parentb1befc77f6b76dfd49a66de04060c4a37e759160
MFC r274898:

Fix the following -Werror warnings from clang 3.5.0, while building
usr.sbin/rtadvd:

usr.sbin/rtadvd/rtadvd.c:1291:7: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
                    abs(preferred_time - pfx->pfx_pltimeexpire) > rai->rai_clockskew) {
                    ^
usr.sbin/rtadvd/rtadvd.c:1291:7: note: remove the call to 'abs' since unsigned values cannot be negative
                    abs(preferred_time - pfx->pfx_pltimeexpire) > rai->rai_clockskew) {
                    ^~~
usr.sbin/rtadvd/rtadvd.c:1324:7: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
                    abs(valid_time - pfx->pfx_vltimeexpire) > rai->rai_clockskew) {
                    ^
usr.sbin/rtadvd/rtadvd.c:1324:7: note: remove the call to 'abs' since unsigned values cannot be negative
                    abs(valid_time - pfx->pfx_vltimeexpire) > rai->rai_clockskew) {
                    ^~~
2 errors generated.

These warnings occur because both preferred_time and pfx_pltimeexpire
are uint32_t's, 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: hrs
Differential Revision: https://reviews.freebsd.org/D1197

git-svn-id: svn://svn.freebsd.org/base/stable/8@275038 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
usr.sbin/rtadvd/rtadvd.c