Page MenuHomeFreeBSD

Fix clang 3.7.0 warnings in lib/libfetch/http.c
ClosedPublic

Authored by dim on May 30 2015, 4:47 PM.
Tags
None
Referenced Files
F156831814: D2673.id.diff
Sat, May 16, 6:57 PM
F156809848: D2673.id5805.diff
Sat, May 16, 2:14 PM
Unknown Object (File)
Wed, May 6, 11:50 AM
Unknown Object (File)
Mon, Apr 27, 4:45 PM
Unknown Object (File)
Tue, Apr 21, 9:53 AM
Unknown Object (File)
Tue, Apr 21, 9:53 AM
Unknown Object (File)
Mon, Apr 20, 10:20 AM
Unknown Object (File)
Mon, Apr 20, 6:57 AM
Subscribers

Details

Summary

Building world with clang 3.7.0, I got these -Werror warnings in lib/libfetch/http.c:

lib/libfetch/http.c:1628:26: error: address of array 'purl->user' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                                aparams.user = purl->user ?
                                               ~~~~~~^~~~ ~
lib/libfetch/http.c:1630:30: error: address of array 'purl->pwd' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                                aparams.password = purl->pwd?
                                                   ~~~~~~^~~~
lib/libfetch/http.c:1657:25: error: address of array 'url->user' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                                aparams.user = url->user ?
                                               ~~~~~^~~~ ~
lib/libfetch/http.c:1659:29: error: address of array 'url->pwd' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                                aparams.password = url->pwd ?
                                                   ~~~~~^~~ ~
lib/libfetch/http.c:1669:25: error: address of array 'url->user' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                                aparams.user = url->user ?
                                               ~~~~~^~~~ ~
lib/libfetch/http.c:1671:29: error: address of array 'url->pwd' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                                aparams.password = url->pwd ?
                                                   ~~~~~^~~ ~

Since url::user and url::pwd are arrays, they can never be NULL, so the checks can be removed.

Test Plan

It builds after this diff. :)

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dim retitled this revision from to Fix clang 3.7.0 warnings in lib/libfetch/http.c.
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added reviewers: des, bapt.
dim set the repository for this revision to rS FreeBSD src repository - subversion.
lib/libfetch/http.c
1629

if purl->user is not null and purl->pwd is null then you strdup a null entry here

lib/libfetch/http.c
1629

purl->pwd can never be NULL, since it is an array. If you mean that purl->pwd[0] is a NUL byte, then that is no problem, since it is equivalent to strdup("") in that case. Similar for the case when purl->user[0] is a NUL byte.

bapt edited edge metadata.
This revision is now accepted and ready to land.Jun 13 2015, 2:27 PM
This revision was automatically updated to reflect the committed changes.