[PATCH uclient 03/12] Fix extra compiler warnings

Petr Štetiar ynezz at true.cz
Thu Dec 10 10:47:50 EST 2020


Fixes following -Wextra compiler warnings:

 uclient.c:195:16: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
         for (i = 0; i < ARRAY_SIZE(backends); i++) {
                     ~ ^ ~~~~~~~~~~~~~~~~~~~~

 uclient-http.c:619:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
         blobmsg_for_each_attr(cur, uh->headers.head, rem)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 uclient-http.c:619:2: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
         blobmsg_for_each_attr(cur, uh->headers.head, rem)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 uclient-http.c:993:16: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
         for (i = 0; i < ARRAY_SIZE(request_types); i++) {
                     ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~

 uclient.c:195:16: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
         for (i = 0; i < ARRAY_SIZE(backends); i++) {
                     ~ ^ ~~~~~~~~~~~~~~~~~~~~

 uclient-http.c:619:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
         blobmsg_for_each_attr(cur, uh->headers.head, rem)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 uclient-http.c:619:2: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
         blobmsg_for_each_attr(cur, uh->headers.head, rem)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 uclient-http.c:993:16: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
         for (i = 0; i < ARRAY_SIZE(request_types); i++) {
                     ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~

 uclient-fetch.c:551:67: error: missing field 'flag' initializer [-Werror,-Wmissing-field-initializers]
         [L_NO_CHECK_CERTIFICATE] = { "no-check-certificate", no_argument },

Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 uclient-fetch.c | 30 +++++++++++++++---------------
 uclient-http.c  |  5 +++--
 uclient.c       |  2 +-
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/uclient-fetch.c b/uclient-fetch.c
index 061f0fd4f808..5f7ac6200bb8 100644
--- a/uclient-fetch.c
+++ b/uclient-fetch.c
@@ -497,7 +497,7 @@ static int usage(const char *progname)
 static void init_ca_cert(void)
 {
 	glob_t gl;
-	int i;
+	unsigned int i;
 
 	glob("/etc/ssl/certs/*.crt", 0, NULL, &gl);
 	for (i = 0; i < gl.gl_pathc; i++)
@@ -548,20 +548,20 @@ enum {
 };
 
 static const struct option longopts[] = {
-	[L_NO_CHECK_CERTIFICATE] = { "no-check-certificate", no_argument },
-	[L_CA_CERTIFICATE] = { "ca-certificate", required_argument },
-	[L_CIPHERS] = { "ciphers", required_argument },
-	[L_USER] = { "user", required_argument },
-	[L_PASSWORD] = { "password", required_argument },
-	[L_USER_AGENT] = { "user-agent", required_argument },
-	[L_POST_DATA] = { "post-data", required_argument },
-	[L_POST_FILE] = { "post-file", required_argument },
-	[L_SPIDER] = { "spider", no_argument },
-	[L_TIMEOUT] = { "timeout", required_argument },
-	[L_CONTINUE] = { "continue", no_argument },
-	[L_PROXY] = { "proxy", required_argument },
-	[L_NO_PROXY] = { "no-proxy", no_argument },
-	[L_QUIET] = { "quiet", no_argument },
+	[L_NO_CHECK_CERTIFICATE] = { "no-check-certificate", no_argument, NULL, 0 },
+	[L_CA_CERTIFICATE] = { "ca-certificate", required_argument, NULL, 0 },
+	[L_CIPHERS] = { "ciphers", required_argument, NULL, 0 },
+	[L_USER] = { "user", required_argument, NULL, 0 },
+	[L_PASSWORD] = { "password", required_argument, NULL, 0 },
+	[L_USER_AGENT] = { "user-agent", required_argument, NULL, 0 },
+	[L_POST_DATA] = { "post-data", required_argument, NULL, 0 },
+	[L_POST_FILE] = { "post-file", required_argument, NULL, 0 },
+	[L_SPIDER] = { "spider", no_argument, NULL, 0 },
+	[L_TIMEOUT] = { "timeout", required_argument, NULL, 0 },
+	[L_CONTINUE] = { "continue", no_argument, NULL, 0 },
+	[L_PROXY] = { "proxy", required_argument, NULL, 0 },
+	[L_NO_PROXY] = { "no-proxy", no_argument, NULL, 0 },
+	[L_QUIET] = { "quiet", no_argument, NULL, 0 },
 	{}
 };
 
diff --git a/uclient-http.c b/uclient-http.c
index c1f722878df7..279669620ebe 100644
--- a/uclient-http.c
+++ b/uclient-http.c
@@ -596,7 +596,8 @@ uclient_http_send_headers(struct uclient_http *uh)
 	struct blob_attr *cur;
 	enum request_type req_type = uh->req_type;
 	bool literal_ipv6;
-	int err, rem;
+	int err;
+	size_t rem;
 
 	if (uh->state >= HTTP_STATE_HEADERS_SENT)
 		return 0;
@@ -982,7 +983,7 @@ int
 uclient_http_set_request_type(struct uclient *cl, const char *type)
 {
 	struct uclient_http *uh = container_of(cl, struct uclient_http, uc);
-	int i;
+	unsigned int i;
 
 	if (cl->backend != &uclient_backend_http)
 		return -1;
diff --git a/uclient.c b/uclient.c
index 9f98cbca167f..95e4585a61cf 100644
--- a/uclient.c
+++ b/uclient.c
@@ -190,7 +190,7 @@ uclient_get_url(const char *url_str, const char *auth_str)
 	struct uclient_url *url;
 	const char *location;
 	int host_len;
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(backends); i++) {
 		int prefix_len = 0;



More information about the openwrt-devel mailing list