From e6b5b8a98ce21d4b8374370b5d7592ead4b351e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Tue, 8 Dec 2020 17:29:57 +0100 Subject: [PATCH] Fix extra compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- 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 061f0fd..5f7ac62 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 c1f7228..2796696 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 9f98cbc..95e4585 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; -- 2.30.2