{"thread":{"id":"7599","subject":"Cygwin and git 1.5.1","startedAt":"2007-04-10T17:39:12Z","lastAt":"2007-04-14T17:53:34Z","messageCount":4,"participants":["Ramsay Jones","H. Peter Anvin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"39035","messageId":"461BCBC0.2000705@ramsay1.demon.co.uk","threadId":"7599","inReplyTo":null,"subject":"Cygwin and git 1.5.1","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2007-04-10T17:39:12Z","receivedAt":"2007-04-10T17:39:12Z","isPatch":false,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Hi Junio,\n\nI recently upgraded to 1.5.1, via tarball as usual, without much problem.\nThe only problem being the \"printf format warnings\" issue, which prevents\nme building with -Werror.\n\nI have included, below, an updated version of my patch from the 1.5.0 series.\nWe agreed last time that this patch is not the correct solution to this\nproblem in general (but it works on cygwin!), so this is *not* intended\nfor submission. I just wanted to document the problem. As before, I don't\nreally have a solution; I suppose I will just have to carry this patch\nforward with each release - no big deal.\n\nNote that the patch has grown larger. This is due to the increased use of\nuint32_t (in combination with printf/die/error etc).\nI guess not many others use -Werror to build on cygwin! ;-)\n\nAll the best,\n\nRamsay Jones\n\n--- >8 ---\n From b2610fc65e42cd6a9acadb20343bddee7c1e3cec Mon Sep 17 00:00:00 2001\nFrom: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\nDate: Mon, 9 Apr 2007 16:41:43 +0100\nSubject: [PATCH] Fix some \"printf format\" warnings.\n\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n  builtin-ls-files.c       |    2 +-\n  builtin-pack-objects.c   |   20 ++++++++++----------\n  builtin-unpack-objects.c |    2 +-\n  fetch-pack.c             |    2 +-\n  index-pack.c             |    2 +-\n  merge-index.c            |    2 +-\n  pack-check.c             |    2 +-\n  read-cache.c             |    2 +-\n  receive-pack.c           |    2 +-\n  sha1_file.c              |    6 +++---\n  unpack-trees.c           |    2 +-\n  11 files changed, 22 insertions(+), 22 deletions(-)\n\ndiff --git a/builtin-ls-files.c b/builtin-ls-files.c\nindex 4e1d5af..310952a 100644\n--- a/builtin-ls-files.c\n+++ b/builtin-ls-files.c\n@@ -193,7 +193,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)\n  \t\tputchar(line_terminator);\n  \t}\n  \telse {\n-\t\tprintf(\"%s%06o %s %d\\t\",\n+\t\tprintf(\"%s%06lo %s %d\\t\",\n  \t\t       tag,\n  \t\t       ntohl(ce->ce_mode),\n  \t\t       abbrev ? find_unique_abbrev(ce->sha1,abbrev)\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex b5f9648..b40e617 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -532,7 +532,7 @@ static void write_pack_file(void)\n  \t\tf = sha1create(\"%s-%s.%s\", base_name,\n  \t\t\t       sha1_to_hex(object_list_sha1), \"pack\");\n  \tif (do_progress)\n-\t\tfprintf(stderr, \"Writing %u objects.\\n\", nr_result);\n+\t\tfprintf(stderr, \"Writing %lu objects.\\n\", nr_result);\n\n  \thdr.hdr_signature = htonl(PACK_SIGNATURE);\n  \thdr.hdr_version = htonl(PACK_VERSION);\n@@ -546,7 +546,7 @@ static void write_pack_file(void)\n  \t\tif (do_progress) {\n  \t\t\tunsigned percent = written * 100 / nr_result;\n  \t\t\tif (progress_update || percent != last_percent) {\n-\t\t\t\tfprintf(stderr, \"%4u%% (%u/%u) done\\r\",\n+\t\t\t\tfprintf(stderr, \"%4u%% (%lu/%lu) done\\r\",\n  \t\t\t\t\tpercent, written, nr_result);\n  \t\t\t\tprogress_update = 0;\n  \t\t\t\tlast_percent = percent;\n@@ -557,7 +557,7 @@ static void write_pack_file(void)\n  \t\tfputc('\\n', stderr);\n   done:\n  \tif (written != nr_result)\n-\t\tdie(\"wrote %u objects while expecting %u\", written, nr_result);\n+\t\tdie(\"wrote %lu objects while expecting %lu\", written, nr_result);\n  \tsha1close(f, pack_file_sha1, 1);\n  }\n\n@@ -716,7 +716,7 @@ static int add_object_entry(const unsigned char *sha1, unsigned hash, int exclud\n\n   already_added:\n  \tif (progress_update) {\n-\t\tfprintf(stderr, \"Counting objects...%u\\r\", nr_objects);\n+\t\tfprintf(stderr, \"Counting objects...%lu\\r\", nr_objects);\n  \t\tprogress_update = 0;\n  \t}\n  \tif (exclude)\n@@ -1286,7 +1286,7 @@ static void find_deltas(struct object_entry **list, int window, int depth)\n  \tarray = xmalloc(array_size);\n  \tmemset(array, 0, array_size);\n  \tif (progress)\n-\t\tfprintf(stderr, \"Deltifying %u objects.\\n\", nr_result);\n+\t\tfprintf(stderr, \"Deltifying %lu objects.\\n\", nr_result);\n\n  \tdo {\n  \t\tstruct object_entry *entry = list[--i];\n@@ -1299,7 +1299,7 @@ static void find_deltas(struct object_entry **list, int window, int depth)\n  \t\tif (progress) {\n  \t\t\tunsigned percent = processed * 100 / nr_result;\n  \t\t\tif (percent != last_percent || progress_update) {\n-\t\t\t\tfprintf(stderr, \"%4u%% (%u/%u) done\\r\",\n+\t\t\t\tfprintf(stderr, \"%4u%% (%lu/%lu) done\\r\",\n  \t\t\t\t\tpercent, processed, nr_result);\n  \t\t\t\tprogress_update = 0;\n  \t\t\t\tlast_percent = percent;\n@@ -1383,7 +1383,7 @@ static int reuse_cached_pack(unsigned char *sha1)\n  \t}\n\n  \tif (progress)\n-\t\tfprintf(stderr, \"Reusing %u objects pack %s\\n\", nr_objects,\n+\t\tfprintf(stderr, \"Reusing %lu objects pack %s\\n\", nr_objects,\n  \t\t\tsha1_to_hex(sha1));\n\n  \tif (pack_to_stdout) {\n@@ -1667,7 +1667,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n  \t}\n\n  \tif (progress)\n-\t\tfprintf(stderr, \"Done counting %u objects.\\n\", nr_objects);\n+\t\tfprintf(stderr, \"Done counting %lu objects.\\n\", nr_objects);\n  \tsorted_by_sha = create_final_object_list();\n  \tif (non_empty && !nr_result)\n  \t\treturn 0;\n@@ -1680,7 +1680,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n  \t}\n  \tSHA1_Final(object_list_sha1, &ctx);\n  \tif (progress && (nr_objects != nr_result))\n-\t\tfprintf(stderr, \"Result has %u objects.\\n\", nr_result);\n+\t\tfprintf(stderr, \"Result has %lu objects.\\n\", nr_result);\n\n  \tif (reuse_cached_pack(object_list_sha1))\n  \t\t;\n@@ -1701,7 +1701,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n  \t\t}\n  \t}\n  \tif (progress)\n-\t\tfprintf(stderr, \"Total %u (delta %u), reused %u (delta %u)\\n\",\n+\t\tfprintf(stderr, \"Total %lu (delta %lu), reused %lu (delta %lu)\\n\",\n  \t\t\twritten, written_delta, reused, reused_delta);\n  \treturn 0;\n  }\ndiff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c\nindex 3956c56..67783fe 100644\n--- a/builtin-unpack-objects.c\n+++ b/builtin-unpack-objects.c\n@@ -324,7 +324,7 @@ static void unpack_all(void)\n  \tif (ntohl(hdr->hdr_signature) != PACK_SIGNATURE)\n  \t\tdie(\"bad pack file\");\n  \tif (!pack_version_ok(hdr->hdr_version))\n-\t\tdie(\"unknown pack file version %d\", ntohl(hdr->hdr_version));\n+\t\tdie(\"unknown pack file version %ld\", ntohl(hdr->hdr_version));\n  \tfprintf(stderr, \"Unpacking %d objects\\n\", nr_objects);\n\n  \tobj_list = xmalloc(nr_objects * sizeof(*obj_list));\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 06f4aec..8cc9888 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -512,7 +512,7 @@ static int get_pack(int xd[2])\n\n  \t\tif (read_pack_header(fd[0], &header))\n  \t\t\tdie(\"protocol error: bad pack header\");\n-\t\tsnprintf(hdr_arg, sizeof(hdr_arg), \"--pack_header=%u,%u\",\n+\t\tsnprintf(hdr_arg, sizeof(hdr_arg), \"--pack_header=%lu,%lu\",\n  \t\t\t ntohl(header.hdr_version), ntohl(header.hdr_entries));\n  \t\tif (ntohl(header.hdr_entries) < unpack_limit)\n  \t\t\tdo_keep = 0;\ndiff --git a/index-pack.c b/index-pack.c\nindex 3c768fb..198e694 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -167,7 +167,7 @@ static void parse_pack_header(void)\n  \tif (hdr->hdr_signature != htonl(PACK_SIGNATURE))\n  \t\tdie(\"pack signature mismatch\");\n  \tif (!pack_version_ok(hdr->hdr_version))\n-\t\tdie(\"pack version %d unsupported\", ntohl(hdr->hdr_version));\n+\t\tdie(\"pack version %ld unsupported\", ntohl(hdr->hdr_version));\n\n  \tnr_objects = ntohl(hdr->hdr_entries);\n  \tuse(sizeof(struct pack_header));\ndiff --git a/merge-index.c b/merge-index.c\nindex 5599fd3..4437355 100644\n--- a/merge-index.c\n+++ b/merge-index.c\n@@ -48,7 +48,7 @@ static int merge_entry(int pos, const char *path)\n  \t\t\tbreak;\n  \t\tfound++;\n  \t\tstrcpy(hexbuf[stage], sha1_to_hex(ce->sha1));\n-\t\tsprintf(ownbuf[stage], \"%o\", ntohl(ce->ce_mode));\n+\t\tsprintf(ownbuf[stage], \"%lo\", ntohl(ce->ce_mode));\n  \t\targuments[stage] = hexbuf[stage];\n  \t\targuments[stage + 4] = ownbuf[stage];\n  \t} while (++pos < active_nr);\ndiff --git a/pack-check.c b/pack-check.c\nindex d988322..592a0ce 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -116,7 +116,7 @@ static void show_pack_info(struct packed_git *p)\n  \tfor (i = 0; i < MAX_CHAIN; i++) {\n  \t\tif (!chain_histogram[i])\n  \t\t\tcontinue;\n-\t\tprintf(\"chain length %s %d: %d object%s\\n\",\n+\t\tprintf(\"chain length %s %ld: %ld object%s\\n\",\n  \t\t       i ? \"=\" : \">=\",\n  \t\t       i ? i : MAX_CHAIN,\n  \t\t       chain_histogram[i],\ndiff --git a/read-cache.c b/read-cache.c\nindex 6339a27..9c274d9 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -130,7 +130,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)\n  \t\t\tchanged |= TYPE_CHANGED;\n  \t\tbreak;\n  \tdefault:\n-\t\tdie(\"internal error: ce_mode is %o\", ntohl(ce->ce_mode));\n+\t\tdie(\"internal error: ce_mode is %lo\", ntohl(ce->ce_mode));\n  \t}\n  \tif (ce->ce_mtime.sec != htonl(st->st_mtime))\n  \t\tchanged |= MTIME_CHANGED;\ndiff --git a/receive-pack.c b/receive-pack.c\nindex 26aa26b..bdabdd9 100644\n--- a/receive-pack.c\n+++ b/receive-pack.c\n@@ -352,7 +352,7 @@ static const char *unpack(void)\n  \thdr_err = parse_pack_header(&hdr);\n  \tif (hdr_err)\n  \t\treturn hdr_err;\n-\tsnprintf(hdr_arg, sizeof(hdr_arg), \"--pack_header=%u,%u\",\n+\tsnprintf(hdr_arg, sizeof(hdr_arg), \"--pack_header=%lu,%lu\",\n  \t\t\tntohl(hdr.hdr_version), ntohl(hdr.hdr_entries));\n\n  \tif (ntohl(hdr.hdr_entries) < unpack_limit) {\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 9c26038..187a109 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -600,14 +600,14 @@ static int open_packed_git_1(struct packed_git *p)\n  \tif (hdr.hdr_signature != htonl(PACK_SIGNATURE))\n  \t\treturn error(\"file %s is not a GIT packfile\", p->pack_name);\n  \tif (!pack_version_ok(hdr.hdr_version))\n-\t\treturn error(\"packfile %s is version %u and not supported\"\n+\t\treturn error(\"packfile %s is version %lu and not supported\"\n  \t\t\t\" (try upgrading GIT to a newer version)\",\n  \t\t\tp->pack_name, ntohl(hdr.hdr_version));\n\n  \t/* Verify the pack matches its index. */\n  \tif (num_packed_objects(p) != ntohl(hdr.hdr_entries))\n-\t\treturn error(\"packfile %s claims to have %u objects\"\n-\t\t\t\" while index size indicates %u objects\",\n+\t\treturn error(\"packfile %s claims to have %lu objects\"\n+\t\t\t\" while index size indicates %lu objects\",\n  \t\t\tp->pack_name, ntohl(hdr.hdr_entries),\n  \t\t\tnum_packed_objects(p));\n  \tif (lseek(p->pack_fd, p->pack_size - sizeof(sha1), SEEK_SET) == -1)\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex ee10eea..5063059 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -538,7 +538,7 @@ static void show_stage_entry(FILE *o,\n  \tif (!ce)\n  \t\tfprintf(o, \"%s (missing)\\n\", label);\n  \telse\n-\t\tfprintf(o, \"%s%06o %s %d\\t%s\\n\",\n+\t\tfprintf(o, \"%s%06lo %s %d\\t%s\\n\",\n  \t\t\tlabel,\n  \t\t\tntohl(ce->ce_mode),\n  \t\t\tsha1_to_hex(ce->sha1),\n-- \n1.5.1\n"},{"id":"39071","messageId":"461C134D.8020803@zytor.com","threadId":"7599","inReplyTo":"461BCBC0.2000705@ramsay1.demon.co.uk","subject":"Re: Cygwin and git 1.5.1","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2007-04-10T22:44:29Z","receivedAt":"2007-04-10T22:44:29Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Ramsay Jones wrote:\n> Hi Junio,\n> \n> I recently upgraded to 1.5.1, via tarball as usual, without much problem.\n> The only problem being the \"printf format warnings\" issue, which prevents\n> me building with -Werror.\n> \n> I have included, below, an updated version of my patch from the 1.5.0 \n> series.\n> We agreed last time that this patch is not the correct solution to this\n> problem in general (but it works on cygwin!), so this is *not* intended\n> for submission. I just wanted to document the problem. As before, I don't\n> really have a solution; I suppose I will just have to carry this patch\n> forward with each release - no big deal.\n> \n> Note that the patch has grown larger. This is due to the increased use of\n> uint32_t (in combination with printf/die/error etc).\n> I guess not many others use -Werror to build on cygwin! ;-)\n\nThe excruciatingly correct way to do this is to use the macros defined \nin <inttypes.h>, so for uint32_t one should use %\"PRNu32\" instead of %u, \nfor example.\n\n\t-hpa\n"},{"id":"39340","messageId":"46210DA4.1090600@ramsay1.demon.co.uk","threadId":"7599","inReplyTo":"461C134D.8020803@zytor.com","subject":"Re: Cygwin and git 1.5.1","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2007-04-14T17:21:40Z","receivedAt":"2007-04-14T17:21:40Z","isPatch":false,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"H. Peter Anvin wrote:\n> Ramsay Jones wrote:\n>> Hi Junio,\n>>\n>> I recently upgraded to 1.5.1, via tarball as usual, without much problem.\n>> The only problem being the \"printf format warnings\" issue, which prevents\n>> me building with -Werror.\n>>\n>> I have included, below, an updated version of my patch from the 1.5.0 \n>> series.\n>> We agreed last time that this patch is not the correct solution to this\n>> problem in general (but it works on cygwin!), so this is *not* intended\n>> for submission. I just wanted to document the problem. As before, I don't\n>> really have a solution; I suppose I will just have to carry this patch\n>> forward with each release - no big deal.\n>>\n>> Note that the patch has grown larger. This is due to the increased use of\n>> uint32_t (in combination with printf/die/error etc).\n>> I guess not many others use -Werror to build on cygwin! ;-)\n> \n> The excruciatingly correct way to do this is to use the macros defined \n> in <inttypes.h>, so for uint32_t one should use %\"PRNu32\" instead of %u, \n> for example.\n> \n>     -hpa\n> \n\nYes, that would work. However, I rejected this solution last time, because\nI did not want to add a dependency on the C99 header files.\nHaving said that, that ship has probably sailed ... ;-)\n\nMaybe I will rework the patch to see how it looks. (I suspect that, while\nit will be better than sprinkling casts about the place, it will probably\nlook quite ugly ;-P)\n\nAll the best,\n\nRamsay Jones\n"},{"id":"39344","messageId":"4621151E.9070707@zytor.com","threadId":"7599","inReplyTo":"46210DA4.1090600@ramsay1.demon.co.uk","subject":"Re: Cygwin and git 1.5.1","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2007-04-14T17:53:34Z","receivedAt":"2007-04-14T17:53:34Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Ramsay Jones wrote:\n> \n> Yes, that would work. However, I rejected this solution last time, because\n> I did not want to add a dependency on the C99 header files.\n> Having said that, that ship has probably sailed ... ;-)\n> \n\nIf you're using uint32_t and similar types, well, then, you're using \n<inttypes.h>.  Now, <inttypes.h> can be written up for an old compiler \nfairly easily.\n\n\t-hpa\n"}]}