Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Jun 2015 19:26:48 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r284346 - head/lib/libfetch
Message-ID:  <201506131926.t5DJQmwx037295@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sat Jun 13 19:26:48 2015
New Revision: 284346
URL: https://svnweb.freebsd.org/changeset/base/284346

Log:
  Fix the following clang 3.7.0 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.
  
  Reviewed by:	bapt
  MFC after:	3 days
  Differential Revision: https://reviews.freebsd.org/D2673

Modified:
  head/lib/libfetch/http.c

Modified: head/lib/libfetch/http.c
==============================================================================
--- head/lib/libfetch/http.c	Sat Jun 13 19:20:56 2015	(r284345)
+++ head/lib/libfetch/http.c	Sat Jun 13 19:26:48 2015	(r284346)
@@ -1625,10 +1625,8 @@ http_request_body(struct url *URL, const
 			http_auth_params_t aparams;
 			init_http_auth_params(&aparams);
 			if (*purl->user || *purl->pwd) {
-				aparams.user = purl->user ?
-					strdup(purl->user) : strdup("");
-				aparams.password = purl->pwd?
-					strdup(purl->pwd) : strdup("");
+				aparams.user = strdup(purl->user);
+				aparams.password = strdup(purl->pwd);
 			} else if ((p = getenv("HTTP_PROXY_AUTH")) != NULL &&
 				   *p != '\0') {
 				if (http_authfromenv(p, &aparams) < 0) {
@@ -1654,10 +1652,8 @@ http_request_body(struct url *URL, const
 			http_auth_params_t aparams;
 			init_http_auth_params(&aparams);
 			if (*url->user || *url->pwd) {
-				aparams.user = url->user ?
-					strdup(url->user) : strdup("");
-				aparams.password = url->pwd ?
-					strdup(url->pwd) : strdup("");
+				aparams.user = strdup(url->user);
+				aparams.password = strdup(url->pwd);
 			} else if ((p = getenv("HTTP_AUTH")) != NULL &&
 				   *p != '\0') {
 				if (http_authfromenv(p, &aparams) < 0) {
@@ -1666,10 +1662,8 @@ http_request_body(struct url *URL, const
 				}
 			} else if (fetchAuthMethod &&
 				   fetchAuthMethod(url) == 0) {
-				aparams.user = url->user ?
-					strdup(url->user) : strdup("");
-				aparams.password = url->pwd ?
-					strdup(url->pwd) : strdup("");
+				aparams.user = strdup(url->user);
+				aparams.password = strdup(url->pwd);
 			} else {
 				http_seterr(HTTP_NEED_AUTH);
 				goto ouch;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506131926.t5DJQmwx037295>