{"thread":{"id":"40780","subject":"[PATCH] http: fix some printf format warnings","startedAt":"2015-11-12T00:07:42Z","lastAt":"2015-11-12T00:11:34Z","messageCount":2,"participants":["Ramsay Jones","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"273236","messageId":"5643D84E.2070904@ramsayjones.plus.com","threadId":"40780","inReplyTo":null,"subject":"[PATCH] http: fix some printf format warnings","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2015-11-12T00:07:42Z","receivedAt":"2015-11-12T00:07:42Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nCommit f8117f55 (\"http: use off_t to store partial file size\",\n02-11-2015) changed the type of some variables from long to off_t.\nUnfortunately, the off_t type is not portable and can be represented\nby several different actual types (even multiple types on the same\nplatform). This makes it difficult to print an off_t variable in\na platform independent way. As a result, this commit causes gcc to\nissue some printf format warnings on a couple of different platforms.\n\nIn order to suppress the warnings, change the format specifier to use\nthe PRIuMAX macro and cast the off_t argument to uintmax_t. (See also\nthe http_opt_request_remainder() function, which uses the same\nsolution).\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n http.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 42f29ce..2532976 100644\n--- a/http.c\n+++ b/http.c\n@@ -1617,8 +1617,8 @@ struct http_pack_request *new_http_pack_request(\n \tif (prev_posn>0) {\n \t\tif (http_is_verbose)\n \t\t\tfprintf(stderr,\n-\t\t\t\t\"Resuming fetch of pack %s at byte %ld\\n\",\n-\t\t\t\tsha1_to_hex(target->sha1), prev_posn);\n+\t\t\t\t\"Resuming fetch of pack %s at byte %\"PRIuMAX\"\\n\",\n+\t\t\t\tsha1_to_hex(target->sha1), (uintmax_t)prev_posn);\n \t\thttp_opt_request_remainder(preq->slot->curl, prev_posn);\n \t}\n \n@@ -1772,8 +1772,8 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \tif (prev_posn>0) {\n \t\tif (http_is_verbose)\n \t\t\tfprintf(stderr,\n-\t\t\t\t\"Resuming fetch of object %s at byte %ld\\n\",\n-\t\t\t\thex, prev_posn);\n+\t\t\t\t\"Resuming fetch of object %s at byte %\"PRIuMAX\"\\n\",\n+\t\t\t\thex, (uintmax_t)prev_posn);\n \t\thttp_opt_request_remainder(freq->slot->curl, prev_posn);\n \t}\n \n-- \n2.6.0\n"},{"id":"273237","messageId":"20151112001134.GA8572@sigill.intra.peff.net","threadId":"40780","inReplyTo":"5643D84E.2070904@ramsayjones.plus.com","subject":"Re: [PATCH] http: fix some printf format warnings","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-11-12T00:11:34Z","receivedAt":"2015-11-12T00:11:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 12, 2015 at 12:07:42AM +0000, Ramsay Jones wrote:\n\n> Commit f8117f55 (\"http: use off_t to store partial file size\",\n> 02-11-2015) changed the type of some variables from long to off_t.\n> Unfortunately, the off_t type is not portable and can be represented\n> by several different actual types (even multiple types on the same\n> platform). This makes it difficult to print an off_t variable in\n> a platform independent way. As a result, this commit causes gcc to\n> issue some printf format warnings on a couple of different platforms.\n> \n> In order to suppress the warnings, change the format specifier to use\n> the PRIuMAX macro and cast the off_t argument to uintmax_t. (See also\n> the http_opt_request_remainder() function, which uses the same\n> solution).\n\nThanks, that's even better than what I had ghost-written for you. :)\n\n-Peff\n"}]}