{"thread":{"id":"40766","subject":"[PATCH] http: fix some printf format warnings on 32-bit builds","startedAt":"2015-11-11T00:23:06Z","lastAt":"2015-11-14T19:14:47Z","messageCount":19,"participants":["Ramsay Jones","Eric Sunshine","Stefan Beller","Lars Schneider","Jeff King","Torsten Bögershausen","Andreas Schwab"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"273167","messageId":"56428A6A.5010406@ramsayjones.plus.com","threadId":"40766","inReplyTo":null,"subject":"[PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2015-11-11T00:23:06Z","receivedAt":"2015-11-11T00:23:06Z","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.\nThe 32-bit build, which enables the large filesystem interface\n(_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\ninteger, whereas long is a 32-bit integer. This results in a couple\nof printf format warnings.\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\nHi Jeff,\n\nI don't compile on 32-bit as often as I did in the past, otherwise I\nwould have noticed this sooner. :(\n\nATB,\nRamsay Jones\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":"273168","messageId":"CAPig+cR+jXgw7+kUK9vrZxNbytwyK3gzgm1YPf_6s57_UxPaBA@mail.gmail.com","threadId":"40766","inReplyTo":"56428A6A.5010406@ramsayjones.plus.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-11T01:22:37Z","receivedAt":"2015-11-11T01:22:37Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n<ramsay@ramsayjones.plus.com> wrote:\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> The 32-bit build, which enables the large filesystem interface\n> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n> integer, whereas long is a 32-bit integer. This results in a couple\n> of printf format warnings.\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\nI just ran across the problem when building 'next' on my Mac and was\nabout to investigate, so am happy to find that the work has already\nbeen done. Thanks.\n\nMy machine is 64-bit, though, so perhaps it's misleading to\ncharacterize this as a fix for 32-bit builds. In particular, off_t is\n'long long' on this machine, so it complains about the \"long\" format\nspecifier.\n\n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n> diff --git a/http.c b/http.c\n> index 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>         if (prev_posn>0) {\n>                 if (http_is_verbose)\n>                         fprintf(stderr,\n> -                               \"Resuming fetch of pack %s at byte %ld\\n\",\n> -                               sha1_to_hex(target->sha1), prev_posn);\n> +                               \"Resuming fetch of pack %s at byte %\"PRIuMAX\"\\n\",\n> +                               sha1_to_hex(target->sha1), (uintmax_t)prev_posn);\n>                 http_opt_request_remainder(preq->slot->curl, prev_posn);\n>         }\n>\n> @@ -1772,8 +1772,8 @@ struct http_object_request *new_http_object_request(const char *base_url,\n>         if (prev_posn>0) {\n>                 if (http_is_verbose)\n>                         fprintf(stderr,\n> -                               \"Resuming fetch of object %s at byte %ld\\n\",\n> -                               hex, prev_posn);\n> +                               \"Resuming fetch of object %s at byte %\"PRIuMAX\"\\n\",\n> +                               hex, (uintmax_t)prev_posn);\n>                 http_opt_request_remainder(freq->slot->curl, prev_posn);\n>         }\n>\n> --\n> 2.6.0\n"},{"id":"273169","messageId":"CAGZ79kb1pDhcP+hN9+C0xK-VYKxfnhvj6a2Len6kOWgmv4+fmQ@mail.gmail.com","threadId":"40766","inReplyTo":"CAPig+cR+jXgw7+kUK9vrZxNbytwyK3gzgm1YPf_6s57_UxPaBA@mail.gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-11-11T02:00:29Z","receivedAt":"2015-11-11T02:00:29Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n> <ramsay@ramsayjones.plus.com> wrote:\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>> The 32-bit build, which enables the large filesystem interface\n>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>> integer, whereas long is a 32-bit integer. This results in a couple\n>> of printf format warnings.\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>\n> I just ran across the problem when building 'next' on my Mac and was\n> about to investigate, so am happy to find that the work has already\n> been done. Thanks.\n>\n> My machine is 64-bit, though, so perhaps it's misleading to\n> characterize this as a fix for 32-bit builds. In particular, off_t is\n> 'long long' on this machine, so it complains about the \"long\" format\n> specifier.\n\n+Lars\n\nI wonder if 32 bit compilation can be part of travis.\n"},{"id":"273178","messageId":"5C9FC321-5B5E-47E6-9BCE-6CDAA41D6E54@gmail.com","threadId":"40766","inReplyTo":"CAGZ79kb1pDhcP+hN9+C0xK-VYKxfnhvj6a2Len6kOWgmv4+fmQ@mail.gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2015-11-11T08:02:52Z","receivedAt":"2015-11-11T08:02:52Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\nOn 11 Nov 2015, at 03:00, Stefan Beller <sbeller@google.com> wrote:\n\n> On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>> <ramsay@ramsayjones.plus.com> wrote:\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>>> The 32-bit build, which enables the large filesystem interface\n>>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>>> integer, whereas long is a 32-bit integer. This results in a couple\n>>> of printf format warnings.\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>> \n>> I just ran across the problem when building 'next' on my Mac and was\n>> about to investigate, so am happy to find that the work has already\n>> been done. Thanks.\n>> \n>> My machine is 64-bit, though, so perhaps it's misleading to\n>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>> 'long long' on this machine, so it complains about the \"long\" format\n>> specifier.\n> \n> +Lars\n> \n> I wonder if 32 bit compilation can be part of travis.\n\nUnfortunately no. All their machines are 64-bit [1] and they have \"no immediate plans to add this feature\" [2].\nHowever, we could the following build configuration on a 64-bit machine:\n\nexport CFLAGS=\"-m32\"\nexport LDFLAGS=\"-m32\"\n\nI think then we could catch these kind of warnings. Do you see a downside with this approach?\n\n- Lars\n\n[1] http://docs.travis-ci.com/user/ci-environment/\n[2] https://github.com/travis-ci/travis-ci/issues/986"},{"id":"273198","messageId":"CAGZ79kbOQk4S3T7b9Ay=NnXnVBhoNLxCKeE6wefhh5qC19+_yg@mail.gmail.com","threadId":"40766","inReplyTo":"5C9FC321-5B5E-47E6-9BCE-6CDAA41D6E54@gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-11-11T17:38:22Z","receivedAt":"2015-11-11T17:38:22Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Nov 11, 2015 at 12:02 AM, Lars Schneider\n<larsxschneider@gmail.com> wrote:\n>\n> Unfortunately no. All their machines are 64-bit [1] and they have \"no immediate plans to add this feature\" [2].\n> However, we could the following build configuration on a 64-bit machine:\n>\n> export CFLAGS=\"-m32\"\n> export LDFLAGS=\"-m32\"\n>\n> I think then we could catch these kind of warnings. Do you see a downside with this approach?\n\nI think that should do it.\n\nAssuming their 64 bit means x86-64 architecture, we may want to prefer\n-mx32, such that we can also test it?\n\n>\n> - Lars\n>\n> [1] http://docs.travis-ci.com/user/ci-environment/\n> [2] https://github.com/travis-ci/travis-ci/issues/986\n"},{"id":"273200","messageId":"56437F3F.7050305@ramsayjones.plus.com","threadId":"40766","inReplyTo":"CAPig+cR+jXgw7+kUK9vrZxNbytwyK3gzgm1YPf_6s57_UxPaBA@mail.gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2015-11-11T17:47:43Z","receivedAt":"2015-11-11T17:47:43Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 11/11/15 01:22, Eric Sunshine wrote:\n> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n> <ramsay@ramsayjones.plus.com> wrote:\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>> The 32-bit build, which enables the large filesystem interface\n>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>> integer, whereas long is a 32-bit integer. This results in a couple\n>> of printf format warnings.\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> \n> I just ran across the problem when building 'next' on my Mac and was\n> about to investigate, so am happy to find that the work has already\n> been done. Thanks.\n\nHmm, interesting. I've never used a Mac, so please forgive my ignorance ...\n\n> My machine is 64-bit, though, so perhaps it's misleading to\n> characterize this as a fix for 32-bit builds. In particular, off_t is\n> 'long long' on this machine, so it complains about the \"long\" format\n> specifier.\n\n... but this seems to imply that sizeof(long) is 4 on your machine, right?\n(on x86_64 linux it's 8, which is why I hadn't noticed before).\n\nJeff, do you need me to re-word the commit message?\n\nATB,\nRamsay Jones\n\n> \n>> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n>> ---\n>> diff --git a/http.c b/http.c\n>> index 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>>         if (prev_posn>0) {\n>>                 if (http_is_verbose)\n>>                         fprintf(stderr,\n>> -                               \"Resuming fetch of pack %s at byte %ld\\n\",\n>> -                               sha1_to_hex(target->sha1), prev_posn);\n>> +                               \"Resuming fetch of pack %s at byte %\"PRIuMAX\"\\n\",\n>> +                               sha1_to_hex(target->sha1), (uintmax_t)prev_posn);\n>>                 http_opt_request_remainder(preq->slot->curl, prev_posn);\n>>         }\n>>\n>> @@ -1772,8 +1772,8 @@ struct http_object_request *new_http_object_request(const char *base_url,\n>>         if (prev_posn>0) {\n>>                 if (http_is_verbose)\n>>                         fprintf(stderr,\n>> -                               \"Resuming fetch of object %s at byte %ld\\n\",\n>> -                               hex, prev_posn);\n>> +                               \"Resuming fetch of object %s at byte %\"PRIuMAX\"\\n\",\n>> +                               hex, (uintmax_t)prev_posn);\n>>                 http_opt_request_remainder(freq->slot->curl, prev_posn);\n>>         }\n>>\n>> --\n>> 2.6.0\n> \n"},{"id":"273201","messageId":"56437F96.2070209@ramsayjones.plus.com","threadId":"40766","inReplyTo":"CAGZ79kb1pDhcP+hN9+C0xK-VYKxfnhvj6a2Len6kOWgmv4+fmQ@mail.gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2015-11-11T17:49:10Z","receivedAt":"2015-11-11T17:49:10Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 11/11/15 02:00, Stefan Beller wrote:\n> On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>> <ramsay@ramsayjones.plus.com> wrote:\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>>> The 32-bit build, which enables the large filesystem interface\n>>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>>> integer, whereas long is a 32-bit integer. This results in a couple\n>>> of printf format warnings.\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>>\n>> I just ran across the problem when building 'next' on my Mac and was\n>> about to investigate, so am happy to find that the work has already\n>> been done. Thanks.\n>>\n>> My machine is 64-bit, though, so perhaps it's misleading to\n>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>> 'long long' on this machine, so it complains about the \"long\" format\n>> specifier.\n> \n> +Lars\n> \n> I wonder if 32 bit compilation can be part of travis.\n> \n\nDid this warning show up on the OS X build?\n\nATB,\nRamsay Jones\n"},{"id":"273223","messageId":"CAPig+cS54yTsZ8NWjyh6kj6nXy966EkYPHh_sjMbMcDGemnFuA@mail.gmail.com","threadId":"40766","inReplyTo":"56437F3F.7050305@ramsayjones.plus.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-11T20:31:01Z","receivedAt":"2015-11-11T20:31:01Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Nov 11, 2015 at 12:47 PM, Ramsay Jones\n<ramsay@ramsayjones.plus.com> wrote:\n> On 11/11/15 01:22, Eric Sunshine wrote:\n>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>> <ramsay@ramsayjones.plus.com> wrote:\n>> My machine is 64-bit, though, so perhaps it's misleading to\n>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>> 'long long' on this machine, so it complains about the \"long\" format\n>> specifier.\n>\n> ... but this seems to imply that sizeof(long) is 4 on your machine, right?\n> (on x86_64 linux it's 8, which is why I hadn't noticed before).\n\nThis code on my Mac:\n\n    printf(\"sizeof(long)=%zu\\n\", sizeof(long));\n    printf(\"sizeof(long long)=%zu\\n\", sizeof(long long));\n    printf(\"sizeof(off_t)=%zu\\n\", sizeof(off_t));\n\nproduces:\n\n    sizeof(long)=8\n    sizeof(long long)=8\n    sizeof(off_t)=8\n\nThe fact that 'long' and 'long long' happen to be the same size (in\nthis case) is immaterial. What is important is that the code is just\nwrong to be using the \"%l\" specifier for 'long' when the actual\ndatatype is 'long long' (which is what 'off_t' is under-the-hood in\nthis case).\n"},{"id":"273228","messageId":"20151111205405.GA31494@sigill.intra.peff.net","threadId":"40766","inReplyTo":"CAPig+cS54yTsZ8NWjyh6kj6nXy966EkYPHh_sjMbMcDGemnFuA@mail.gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-11-11T20:54:06Z","receivedAt":"2015-11-11T20:54:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 11, 2015 at 03:31:01PM -0500, Eric Sunshine wrote:\n\n> The fact that 'long' and 'long long' happen to be the same size (in\n> this case) is immaterial. What is important is that the code is just\n> wrong to be using the \"%l\" specifier for 'long' when the actual\n> datatype is 'long long' (which is what 'off_t' is under-the-hood in\n> this case).\n\nRight. We cannot assume anything about what is in off_t, and should be\ncasting to uintmax_t. So the patch is right, but I agree the commit\nmessage could be better. I started to hack it up myself, but I didn't\nwant to put too many words in Ramsay's mouth. Do you mind resending with\nan updated commit message?\n\nThanks (and thank you in the first place for finding and fixing the\nbreakage I introduced in f8117f55).\n\n-Peff\n"},{"id":"273230","messageId":"5643ABF0.5080207@ramsayjones.plus.com","threadId":"40766","inReplyTo":"CAPig+cS54yTsZ8NWjyh6kj6nXy966EkYPHh_sjMbMcDGemnFuA@mail.gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2015-11-11T20:58:24Z","receivedAt":"2015-11-11T20:58:24Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 11/11/15 20:31, Eric Sunshine wrote:\n> On Wed, Nov 11, 2015 at 12:47 PM, Ramsay Jones\n> <ramsay@ramsayjones.plus.com> wrote:\n>> On 11/11/15 01:22, Eric Sunshine wrote:\n>>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>>> <ramsay@ramsayjones.plus.com> wrote:\n>>> My machine is 64-bit, though, so perhaps it's misleading to\n>>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>>> 'long long' on this machine, so it complains about the \"long\" format\n>>> specifier.\n>>\n>> ... but this seems to imply that sizeof(long) is 4 on your machine, right?\n>> (on x86_64 linux it's 8, which is why I hadn't noticed before).\n> \n> This code on my Mac:\n> \n>     printf(\"sizeof(long)=%zu\\n\", sizeof(long));\n>     printf(\"sizeof(long long)=%zu\\n\", sizeof(long long));\n>     printf(\"sizeof(off_t)=%zu\\n\", sizeof(off_t));\n> \n> produces:\n> \n>     sizeof(long)=8\n>     sizeof(long long)=8\n>     sizeof(off_t)=8\n> \n> The fact that 'long' and 'long long' happen to be the same size (in\n> this case) is immaterial. What is important is that the code is just\n> wrong to be using the \"%l\" specifier for 'long' when the actual\n> datatype is 'long long' (which is what 'off_t' is under-the-hood in\n> this case).\n\nAh. OK, so %ld for long and %lld for long long, I suppose.\n\nHmm, not that it matters, but I wonder what the PRId64 macro is. ;-)\n\nATB,\nRamsay Jones\n"},{"id":"273239","messageId":"5644232C.2060700@web.de","threadId":"40766","inReplyTo":"5643ABF0.5080207@ramsayjones.plus.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-11-12T05:27:08Z","receivedAt":"2015-11-12T05:27:08Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":" >Ah. OK, so %ld for long and %lld for long long, I suppose. Only if you \nhave a system that's support it.\n\nLinux does, Windows not.\n\n>Hmm, not that it matters, but I wonder what the PRId64 macro is. ;-)\nIt's \"I64d\" for Windows, and \"lld\" for all Gnu based systems and others,\n\nWhen you do printf(\"%lld %ld\", long_long_var, long_var),\nthe \"printf runtime\" under Windows will treat \"%lld\" as \"%ld\", and print\nthe lower part of long_long_var.\nAnd will not pull a long long from stack, but a long, resulting i all kinds of confusion\n\nSo whenever a long long is printed, I can warmly recommend to use\n\nPRId64\n"},{"id":"273245","messageId":"56447F02.2000105@ramsayjones.plus.com","threadId":"40766","inReplyTo":"5644232C.2060700@web.de","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2015-11-12T11:58:58Z","receivedAt":"2015-11-12T11:58:58Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 12/11/15 05:27, Torsten Bögershausen wrote:\n>>Ah. OK, so %ld for long and %lld for long long, I suppose.\n> Only if you have a system that's support it.\n> \n> Linux does, Windows not.\n\nSure, but I was speculating specifically about Eric's mac (which I\nhave no experience with).\n\n> \n>> Hmm, not that it matters, but I wonder what the PRId64 macro is. ;-)\n> It's \"I64d\" for Windows, and \"lld\" for all Gnu based systems and others,\n\n[On Gnu systems, I believe it is %lld on 32-bit and %ld on 64-bit.]\n\nAgain, I was commenting on Eric's mac, which _seems_ to allow\nthe use of both %ld and %lld when printing 64-bit integers, so\nwhich does it choose for PRId64 ...\n\n> \n> When you do printf(\"%lld %ld\", long_long_var, long_var),\n> the \"printf runtime\" under Windows will treat \"%lld\" as \"%ld\", and print\n> the lower part of long_long_var.\n> And will not pull a long long from stack, but a long, resulting i all kinds of confusion\n> \n> So whenever a long long is printed, I can warmly recommend to use\n> \n> PRId64\n\nIndeed.\n\nATB,\nRamsay Jones\n"},{"id":"273247","messageId":"87fv0b12ou.fsf@igel.home","threadId":"40766","inReplyTo":"5644232C.2060700@web.de","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2015-11-12T18:40:33Z","receivedAt":"2015-11-12T18:40:33Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> So whenever a long long is printed, I can warmly recommend to use\n>\n> PRId64\n\nPRId64 is not suitable for long long, only for int64_t.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"273271","messageId":"71B4BDE3-153C-4918-A23A-F45F0228A988@gmail.com","threadId":"40766","inReplyTo":"56437F96.2070209@ramsayjones.plus.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2015-11-13T08:46:42Z","receivedAt":"2015-11-13T08:46:42Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\nOn 11 Nov 2015, at 18:49, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:\n\n> \n> \n> On 11/11/15 02:00, Stefan Beller wrote:\n>> On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>>> <ramsay@ramsayjones.plus.com> wrote:\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>>>> The 32-bit build, which enables the large filesystem interface\n>>>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>>>> integer, whereas long is a 32-bit integer. This results in a couple\n>>>> of printf format warnings.\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>>> \n>>> I just ran across the problem when building 'next' on my Mac and was\n>>> about to investigate, so am happy to find that the work has already\n>>> been done. Thanks.\n>>> \n>>> My machine is 64-bit, though, so perhaps it's misleading to\n>>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>>> 'long long' on this machine, so it complains about the \"long\" format\n>>> specifier.\n>> \n>> +Lars\n>> \n>> I wonder if 32 bit compilation can be part of travis.\n>> \n> \n> Did this warning show up on the OS X build?\n\nYes, I added CFLAGS=\"-Werror=format\" to the my experimental TravisCI build and it breaks the build on OS X.\nSee here (you need to scroll all the way down):\nhttps://travis-ci.org/larsxschneider/git/jobs/90899656\n\nBTW: I tried to set \"-Werror\" but then I got a bunch of macro redefined errors like this:\n./git-compat-util.h:614:9: error: 'strlcpy' macro redefined [-Werror]\n\nIs this a known issue? Is this an issue at all?\n\nThanks,\nLars"},{"id":"273272","messageId":"CAPig+cRjDVPHH3VH-Mv_KJTeOVyxV-6agHDk+bXqZ4kjJoaLJQ@mail.gmail.com","threadId":"40766","inReplyTo":"71B4BDE3-153C-4918-A23A-F45F0228A988@gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-13T08:57:43Z","receivedAt":"2015-11-13T08:57:43Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Nov 13, 2015 at 3:46 AM, Lars Schneider\n<larsxschneider@gmail.com> wrote:\n> On 11 Nov 2015, at 18:49, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:\n>> On 11/11/15 02:00, Stefan Beller wrote:\n>>> On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>>>> <ramsay@ramsayjones.plus.com> wrote:\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>>>>> The 32-bit build, which enables the large filesystem interface\n>>>>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>>>>> integer, whereas long is a 32-bit integer. This results in a couple\n>>>>> of printf format warnings.\n>>>>\n>>>> My machine is 64-bit, though, so perhaps it's misleading to\n>>>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>>>> 'long long' on this machine, so it complains about the \"long\" format\n>>>> specifier.\n>>>\n>>> I wonder if 32 bit compilation can be part of travis.\n>>\n>> Did this warning show up on the OS X build?\n>\n> Yes, I added CFLAGS=\"-Werror=format\" to the my experimental TravisCI\n> build and it breaks the build on OS X.\n> See here (you need to scroll all the way down):\n> https://travis-ci.org/larsxschneider/git/jobs/90899656\n>\n> BTW: I tried to set \"-Werror\" but then I got a bunch of macro redefined errors like this:\n> ./git-compat-util.h:614:9: error: 'strlcpy' macro redefined [-Werror]\n>\n> Is this a known issue? Is this an issue at all?\n\nOdd. I don't experience anything like that on my Mac.\n"},{"id":"273274","messageId":"5645BC55.70504@web.de","threadId":"40766","inReplyTo":"CAPig+cRjDVPHH3VH-Mv_KJTeOVyxV-6agHDk+bXqZ4kjJoaLJQ@mail.gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-11-13T10:32:53Z","receivedAt":"2015-11-13T10:32:53Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2015-11-13 09.57, Eric Sunshine wrote:\n> On Fri, Nov 13, 2015 at 3:46 AM, Lars Schneider\n> <larsxschneider@gmail.com> wrote:\n>> On 11 Nov 2015, at 18:49, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:\n>>> On 11/11/15 02:00, Stefan Beller wrote:\n>>>> On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>>>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>>>>> <ramsay@ramsayjones.plus.com> wrote:\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>>>>>> The 32-bit build, which enables the large filesystem interface\n>>>>>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>>>>>> integer, whereas long is a 32-bit integer. This results in a couple\n>>>>>> of printf format warnings.\n>>>>>\n>>>>> My machine is 64-bit, though, so perhaps it's misleading to\n>>>>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>>>>> 'long long' on this machine, so it complains about the \"long\" format\n>>>>> specifier.\n>>>>\n>>>> I wonder if 32 bit compilation can be part of travis.\n>>>\n>>> Did this warning show up on the OS X build?\n>>\n>> Yes, I added CFLAGS=\"-Werror=format\" to the my experimental TravisCI\n>> build and it breaks the build on OS X.\n>> See here (you need to scroll all the way down):\n>> https://travis-ci.org/larsxschneider/git/jobs/90899656\n>>\n>> BTW: I tried to set \"-Werror\" but then I got a bunch of macro redefined errors like this:\n>> ./git-compat-util.h:614:9: error: 'strlcpy' macro redefined [-Werror]\n>>\n>> Is this a known issue? Is this an issue at all?\n> \n> Odd. I don't experience anything like that on my Mac.\n\nCould it be, that strlcpy is present on your system ?\nAnd where does it come from ?\n\nWhich OS ?\nWhich compiler ?\nWhat does `uname -r` say ?\nDo you have Macports, Fink, Brew... installed ?\n"},{"id":"273275","messageId":"23C0ED03-3773-49AC-A03B-F5E35B9E12D0@gmail.com","threadId":"40766","inReplyTo":"5645BC55.70504@web.de","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2015-11-13T12:08:52Z","receivedAt":"2015-11-13T12:08:52Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\n> On 13 Nov 2015, at 11:32, Torsten Bögershausen <tboegi@web.de> wrote:\n> \n> On 2015-11-13 09.57, Eric Sunshine wrote:\n>> On Fri, Nov 13, 2015 at 3:46 AM, Lars Schneider\n>> <larsxschneider@gmail.com> wrote:\n>>> On 11 Nov 2015, at 18:49, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:\n>>>> On 11/11/15 02:00, Stefan Beller wrote:\n>>>>> On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>>>>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>>>>>> <ramsay@ramsayjones.plus.com> wrote:\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>>>>>>> The 32-bit build, which enables the large filesystem interface\n>>>>>>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>>>>>>> integer, whereas long is a 32-bit integer. This results in a couple\n>>>>>>> of printf format warnings.\n>>>>>> \n>>>>>> My machine is 64-bit, though, so perhaps it's misleading to\n>>>>>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>>>>>> 'long long' on this machine, so it complains about the \"long\" format\n>>>>>> specifier.\n>>>>> \n>>>>> I wonder if 32 bit compilation can be part of travis.\n>>>> \n>>>> Did this warning show up on the OS X build?\n>>> \n>>> Yes, I added CFLAGS=\"-Werror=format\" to the my experimental TravisCI\n>>> build and it breaks the build on OS X.\n>>> See here (you need to scroll all the way down):\n>>> https://travis-ci.org/larsxschneider/git/jobs/90899656\n>>> \n>>> BTW: I tried to set \"-Werror\" but then I got a bunch of macro redefined errors like this:\n>>> ./git-compat-util.h:614:9: error: 'strlcpy' macro redefined [-Werror]\n>>> \n>>> Is this a known issue? Is this an issue at all?\n>> \n>> Odd. I don't experience anything like that on my Mac.\n> \n> Could it be, that strlcpy is present on your system ?\n> And where does it come from ?\n> \n> Which OS ?\n> Which compiler ?\n> What does `uname -r` say ?\n> Do you have Macports, Fink, Brew... installed ?\n> \n\nLooks like this is a OS X only issue. Happens with clang and gcc on the OS X Mavericks TravisCI machines [1]:\nhttps://travis-ci.org/larsxschneider/git/jobs/90919078\nhttps://travis-ci.org/larsxschneider/git/jobs/90919080\n\nOn Linux+gcc the following error happens if \"-Werror\" is present:\nhttps://travis-ci.org/larsxschneider/git/jobs/90919076\nDo you have an idea what that might be?\n\nLinux+clang works fine:\nhttps://travis-ci.org/larsxschneider/git/jobs/90919074\n\n- Lars\n\n[1] http://docs.travis-ci.com/user/ci-environment/\n"},{"id":"273288","messageId":"564641CF.5050008@ramsayjones.plus.com","threadId":"40766","inReplyTo":"CAPig+cRjDVPHH3VH-Mv_KJTeOVyxV-6agHDk+bXqZ4kjJoaLJQ@mail.gmail.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2015-11-13T20:02:23Z","receivedAt":"2015-11-13T20:02:23Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 13/11/15 08:57, Eric Sunshine wrote:\n> On Fri, Nov 13, 2015 at 3:46 AM, Lars Schneider\n> <larsxschneider@gmail.com> wrote:\n>> On 11 Nov 2015, at 18:49, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:\n>>> On 11/11/15 02:00, Stefan Beller wrote:\n>>>> On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>>>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>>>>> <ramsay@ramsayjones.plus.com> wrote:\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>>>>>> The 32-bit build, which enables the large filesystem interface\n>>>>>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>>>>>> integer, whereas long is a 32-bit integer. This results in a couple\n>>>>>> of printf format warnings.\n>>>>>\n>>>>> My machine is 64-bit, though, so perhaps it's misleading to\n>>>>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>>>>> 'long long' on this machine, so it complains about the \"long\" format\n>>>>> specifier.\n>>>>\n>>>> I wonder if 32 bit compilation can be part of travis.\n>>>\n>>> Did this warning show up on the OS X build?\n>>\n>> Yes, I added CFLAGS=\"-Werror=format\" to the my experimental TravisCI\n>> build and it breaks the build on OS X.\n>> See here (you need to scroll all the way down):\n>> https://travis-ci.org/larsxschneider/git/jobs/90899656\n>>\n>> BTW: I tried to set \"-Werror\" but then I got a bunch of macro redefined errors like this:\n>> ./git-compat-util.h:614:9: error: 'strlcpy' macro redefined [-Werror]\n>>\n>> Is this a known issue? Is this an issue at all?\n> \n> Odd. I don't experience anything like that on my Mac.\n> \n\nHmm, from the output, it looks like the configure script is\nnot detecting that 'strlcpy' is available (so setting\nNO_STRLCPY=YesPlease in the config.mak.autogen file).\nHowever, it seems to be a 'macro redirect' set in the\n/usr/include/secure/_string.h header file (presumably it\nredirects between a more or less secure version ;-)\n\nUnfortunately, I don't have access to a mac - so I can't\nhelp you with the debugging. :(\n\nATB,\nRamsay Jones\n"},{"id":"273336","messageId":"8823C17E-3F5C-492B-B600-2A73819ECD08@gmail.com","threadId":"40766","inReplyTo":"564641CF.5050008@ramsayjones.plus.com","subject":"Re: [PATCH] http: fix some printf format warnings on 32-bit builds","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2015-11-14T19:14:47Z","receivedAt":"2015-11-14T19:14:47Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\nOn 13 Nov 2015, at 21:02, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:\n\n> \n> \n> On 13/11/15 08:57, Eric Sunshine wrote:\n>> On Fri, Nov 13, 2015 at 3:46 AM, Lars Schneider\n>> <larsxschneider@gmail.com> wrote:\n>>> On 11 Nov 2015, at 18:49, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:\n>>>> On 11/11/15 02:00, Stefan Beller wrote:\n>>>>> On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>>>>> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones\n>>>>>> <ramsay@ramsayjones.plus.com> wrote:\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>>>>>>> The 32-bit build, which enables the large filesystem interface\n>>>>>>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit\n>>>>>>> integer, whereas long is a 32-bit integer. This results in a couple\n>>>>>>> of printf format warnings.\n>>>>>> \n>>>>>> My machine is 64-bit, though, so perhaps it's misleading to\n>>>>>> characterize this as a fix for 32-bit builds. In particular, off_t is\n>>>>>> 'long long' on this machine, so it complains about the \"long\" format\n>>>>>> specifier.\n>>>>> \n>>>>> I wonder if 32 bit compilation can be part of travis.\n>>>> \n>>>> Did this warning show up on the OS X build?\n>>> \n>>> Yes, I added CFLAGS=\"-Werror=format\" to the my experimental TravisCI\n>>> build and it breaks the build on OS X.\n>>> See here (you need to scroll all the way down):\n>>> https://travis-ci.org/larsxschneider/git/jobs/90899656\n>>> \n>>> BTW: I tried to set \"-Werror\" but then I got a bunch of macro redefined errors like this:\n>>> ./git-compat-util.h:614:9: error: 'strlcpy' macro redefined [-Werror]\n>>> \n>>> Is this a known issue? Is this an issue at all?\n>> \n>> Odd. I don't experience anything like that on my Mac.\n>> \n> \n> Hmm, from the output, it looks like the configure script is\n> not detecting that 'strlcpy' is available (so setting\n> NO_STRLCPY=YesPlease in the config.mak.autogen file).\n> However, it seems to be a 'macro redirect' set in the\n> /usr/include/secure/_string.h header file (presumably it\n> redirects between a more or less secure version ;-)\n> \n> Unfortunately, I don't have access to a mac - so I can't\n> help you with the debugging. :(\n> \n\nI don't have any experience with autotools at all. However, here is what I found out on OS X Mavericks (10.9.5):\n1.) In config.mak.uname, line 103, \"NO_STRLCPY = YesPlease\" is set for some old OS X version. However, it looks like these settings have no impact at all.\n2.) In configure.ac, line 1010, the AC_CHECK_FUNC macros (via GIT_CHECK_FUNC) is used to detect strlcpy. That detection fails on OS X Mavericks.\n3.) I tried to use \"AC_CHECK_DECLS\" to detect strlcpy declarations on OS X and this works.\n\nCan you give me a few hints how to debug this further? Why do have the values in config.mak.uname no impact? My idea was to detect OS X Mavericks there and unset NO_STRLCPY. Could that work?\n\nThanks,\nLars \n"}]}