From 74c6f535a93da4ccb20aa1e902eb1e2b8df903a9 Mon Sep 17 00:00:00 2001 From: Jure Grabnar
Date: Thu, 20 Mar 2014 17:16:31 +0100 Subject: [PATCH 2/2] Fix some compiler warnings --- src/ChangeLog | 19 +++++++++++++++++++ src/http.c | 5 +---- src/iri.h | 2 +- src/metalink.c | 13 ++++++------- src/multi.c | 8 ++++++++ src/multi.h | 2 -- src/progress.c | 1 - src/recur.c | 2 ++ src/retr.c | 4 ++-- 9 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6e4729c..c7068f0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,24 @@ 2014-03-20 Jure Grabnar + * http.c (gethttp): Remove unused variable 'tmp2'. + * iri.h: Fix macro parse_charset(str) to not cause 'left-hand operand of + comma expression has no effect'. + * metalink.c (parse_metalink): Remove unused variable 'piece_hash'. + (elect_resources): Add parentheses to assigment. + (elect_checksums): Same. Add cast to (unsigned char *). + (veriy_file_hash): Add casts to (char *). + * multi.h: Remove prototype of static function segmented_retrieve_url(). + * multi.c: Include "retr.h". Add prototype of static function + segmented_retrieve_url(); + (collect_thread): Add return value to suppress compiler warning. + (segmented_retrieve_url): Same. + * recur.c (start_retrieve_url): Same. + * progress.c: Removed unused variable 'header'. + * retr.c (retrieve_from_file): Remove unused variables 'i', 'url_err', + 'retries'. + +2014-03-20 Jure Grabnar + * metalink.c (parse_metalink): Find out resources' protocol type from URL. Do not crash when there're no resources. (elect_resources): Do not crash when protocol type is NULL. diff --git a/src/http.c b/src/http.c index c5c4d8a..fa627a7 100644 --- a/src/http.c +++ b/src/http.c @@ -2872,9 +2872,6 @@ read_header: char *tmp = strchr (type, ';'); if (tmp) { - /* sXXXav: only needed if IRI support is enabled */ - char *tmp2 = tmp + 1; - while (tmp > type && c_isspace (tmp[-1])) --tmp; *tmp = '\0'; @@ -2882,7 +2879,7 @@ read_header: /* Try to get remote encoding if needed */ if (opt.enable_iri && !opt.encoding_remote) { - tmp = parse_charset (tmp2); + tmp = parse_charset (tmp + 1); if (tmp) set_content_encoding (iri, tmp); } diff --git a/src/iri.h b/src/iri.h index e759e45..c88d94f 100644 --- a/src/iri.h +++ b/src/iri.h @@ -56,7 +56,7 @@ void set_content_encoding (struct iri *i, char *charset); extern struct iri dummy_iri; -#define parse_charset(str) (str, NULL) +#define parse_charset(str) (NULL) #define find_locale() NULL #define check_encoding_name(str) false #define locale_to_utf8(str) (str) diff --git a/src/metalink.c b/src/metalink.c index b8cdd28..539a2d0 100644 --- a/src/metalink.c +++ b/src/metalink.c @@ -137,7 +137,7 @@ parse_metalink(char *input_file) resource->url = xstrdup ((*resources)->url); if ((*resources)->type) - resource->type = xstrdup((*resources)->type); + resource->type = xstrdup ((*resources)->type); else { enum url_scheme res_scheme = url_scheme (resource->url); @@ -209,7 +209,6 @@ parse_metalink(char *input_file) chunk_sum->type = (chunk_checksum->type ? xstrdup (chunk_checksum->type) : NULL); for (piece_hashes = chunk_checksum->piece_hashes; *piece_hashes; ++piece_hashes) { - mlink_piece_hash piece_hash; if(!chunk_checksum->type) { logprintf (LOG_VERBOSE, "PARSE METALINK: Skipping chunk checksum" @@ -241,7 +240,7 @@ elect_resources (mlink *mlink) if (!res) continue; - while (res_next = res->next) + while ((res_next = res->next)) { if (res_next->type == NULL || (strcmp(res_next->type, "ftp") && strcmp(res_next->type, "http"))) { @@ -275,7 +274,7 @@ elect_checksums (mlink *mlink) if (!csum) continue; - while (csum_next = csum->next) + while ((csum_next = csum->next)) { /* Traverse supported hash types & break if csum->type is the same. */ for (i = 0; i < HASH_TYPES; ++i) @@ -447,7 +446,7 @@ verify_file_hash (const char *filename, mlink_checksum *checksums) return 1; } else - metalink_hashes[j] = checksum->hash; + metalink_hashes[j] = (unsigned char *) checksum->hash; } for (i = 0; !metalink_hashes[i]; ++i); @@ -482,10 +481,10 @@ verify_file_hash (const char *filename, mlink_checksum *checksums) /* Turn byte-form hash to hex form. */ for(j = 0 ; j < digest_sizes[req_type]; ++j) - sprintf(file_hash + 2 * j, "%02x", hash_raw[j]); + sprintf((char *) file_hash + 2 * j, "%02x", hash_raw[j]); lower_hex_case(metalink_hashes[req_type], 2 * digest_sizes[req_type]); - if (strcmp(metalink_hashes[req_type], file_hash)) + if (strcmp((char *) metalink_hashes[req_type], (char *) file_hash)) { logprintf (LOG_VERBOSE, "Verifying(%s) failed: %s hashes are different.\n", filename, supported_hashes[i]); diff --git a/src/multi.c b/src/multi.c index 4b22b2e..211c449 100644 --- a/src/multi.c +++ b/src/multi.c @@ -38,11 +38,14 @@ as that of the covered work. */ #include