Fix extra compiler warnings
authorPetr Štetiar <ynezz@true.cz>
Tue, 8 Dec 2020 16:29:57 +0000 (17:29 +0100)
committerPetr Štetiar <ynezz@true.cz>
Fri, 11 Dec 2020 10:17:22 +0000 (11:17 +0100)
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@true.cz>
uclient-fetch.c
uclient-http.c
uclient.c

index 061f0fd4f808f5708664cb52d683529bbe95bc04..5f7ac6200bb867690d91468433225820562ad8b3 100644 (file)
@@ -497,7 +497,7 @@ static int usage(const char *progname)
 static void init_ca_cert(void)
 {
        glob_t gl;
 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++)
 
        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[] = {
 };
 
 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 },
        {}
 };
 
        {}
 };
 
index c1f722878df76dc5452f34032ff9aac4f52e9d91..279669620ebe659b5904d6e3275b991e40f1e700 100644 (file)
@@ -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;
        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;
 
        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);
 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;
 
        if (cl->backend != &uclient_backend_http)
                return -1;
index 9f98cbca167f0b5cc419ec1effe542130d1fe6df..95e4585a61cfa0f2ba90985e57d1b685255a1416 100644 (file)
--- 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;
        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;
 
        for (i = 0; i < ARRAY_SIZE(backends); i++) {
                int prefix_len = 0;