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
Unknown Object (File)
Mon, Apr 22, 5:21 AM
Unknown Object (File)
Mon, Apr 22, 5:20 AM
Unknown Object (File)
Mon, Apr 22, 5:20 AM
Unknown Object (File)
Mon, Apr 22, 5:08 AM
Unknown Object (File)
Feb 29 2024, 3:58 PM
Unknown Object (File)
Feb 11 2024, 4:44 AM
Unknown Object (File)
Dec 20 2023, 11:57 AM
Unknown Object (File)
Dec 20 2023, 12:34 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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #5805)

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

lib/libfetch/http.c
1629 ↗(On Diff #5805)

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.