http: fix some printf format warnings

Commit f8117f55 ("http: use off_t to store partial file size", 02-11-2015) changed the type of some variables from long to off_t. Unfortunately, the off_t type is not portable and can be represented by several different actual types (even multiple types on the same platform). This makes it difficult to print an off_t variable in a platform independent way. As a result, this commit causes gcc to issue some printf format warnings on a couple of different platforms. In order to suppress the warnings, change the format specifier to use the PRIuMAX macro and cast the off_t argument to uintmax_t. (See also the http_opt_request_remainder() function, which uses the same solution). Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Jeff King <peff@peff.net>

Ramsay Jones committed Nov 12, 2015 at 00:07 UTC 838ecf0b0f0c66d137065303231e04f85c74c5e3
1 file changed +4 -4
http.c
+4 -4
@@ -1617,8 +1617,8 @@ struct http_pack_request *new_http_pack_request(
1617 if (prev_posn>0) {
1618 if (http_is_verbose)
1619 fprintf(stderr,
1620 - "Resuming fetch of pack %s at byte %ld\n",
1621 - sha1_to_hex(target->sha1), prev_posn);
1620 + "Resuming fetch of pack %s at byte %"PRIuMAX"\n",
1621 + sha1_to_hex(target->sha1), (uintmax_t)prev_posn);
1622 http_opt_request_remainder(preq->slot->curl, prev_posn);
1623 }
1624
@@ -1772,8 +1772,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
1772 if (prev_posn>0) {
1773 if (http_is_verbose)
1774 fprintf(stderr,
1775 - "Resuming fetch of object %s at byte %ld\n",
1776 - hex, prev_posn);
1775 + "Resuming fetch of object %s at byte %"PRIuMAX"\n",
1776 + hex, (uintmax_t)prev_posn);
1777 http_opt_request_remainder(freq->slot->curl, prev_posn);
1778 }
1779