]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/commit
MFC r274847:
authordim <dim@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 25 Nov 2014 12:45:31 +0000 (12:45 +0000)
committerdim <dim@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 25 Nov 2014 12:45:31 +0000 (12:45 +0000)
commit5d61ee346f4c01b733063effa64532dff6e5ba71
treed1f68afc1b0c19753611130750102693d5a1d32a
parent3f8af3d8d5174a4e9ac1b7eb5a2dfdd3f8138a3b
MFC r274847:

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

usr.bin/locate/locate/util.c:249:29: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
                            MAXPATHLEN, abs(i) < abs(htonl(i)) ? i : htonl(i));
                                                 ^
usr.bin/locate/locate/util.c:249:29: note: remove the call to 'abs' since unsigned values cannot be negative
                            MAXPATHLEN, abs(i) < abs(htonl(i)) ? i : htonl(i));
                                                 ^~~
usr.bin/locate/locate/util.c:274:32: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
                            MAXPATHLEN, abs(word) < abs(htonl(word)) ? word :
                                                    ^
usr.bin/locate/locate/util.c:274:32: note: remove the call to 'abs' since unsigned values cannot be negative
                            MAXPATHLEN, abs(word) < abs(htonl(word)) ? word :
                                                    ^~~

The problem is that ntohl() always returns an unsigned quantity.  In
this case, it's expected to be cast back to a signed integer, but to
stop complaints about abs() we just store it into an integer, and don't
call ntohl() again.

Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D1196

git-svn-id: svn://svn.freebsd.org/base/stable/9@275034 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
usr.bin/locate/locate/util.c