Skip to content

Commit 838ecf0

Browse files
ramsay-jonespeff
authored andcommitted
http: fix some printf format warnings
Commit f8117f5 ("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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent f8117f5 commit 838ecf0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

http.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,8 +1617,8 @@ struct http_pack_request *new_http_pack_request(
16171617
if (prev_posn>0) {
16181618
if (http_is_verbose)
16191619
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);
16221622
http_opt_request_remainder(preq->slot->curl, prev_posn);
16231623
}
16241624

@@ -1772,8 +1772,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
17721772
if (prev_posn>0) {
17731773
if (http_is_verbose)
17741774
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);
17771777
http_opt_request_remainder(freq->slot->curl, prev_posn);
17781778
}
17791779

0 commit comments

Comments
 (0)