{"thread":{"id":"25056","subject":"[PATCH] vcs-svn: Fix some printf format compiler warnings","startedAt":"2010-09-09T17:24:06Z","lastAt":"2010-09-11T20:42:56Z","messageCount":2,"participants":["Ramsay Jones","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"150377","messageId":"4C891836.6070608@ramsay1.demon.co.uk","threadId":"25056","inReplyTo":null,"subject":"[PATCH] vcs-svn: Fix some printf format compiler warnings","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2010-09-09T17:24:06Z","receivedAt":"2010-09-09T17:24:06Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nIn particular, on systems that define uint32_t as an unsigned long,\ngcc complains as follows:\n\n    CC vcs-svn/fast_export.o\nvcs-svn/fast_export.c: In function `fast_export_modify':\nvcs-svn/fast_export.c:28: warning: unsigned int format, uint32_t arg (arg 2)\nvcs-svn/fast_export.c:28: warning: int format, uint32_t arg (arg 3)\nvcs-svn/fast_export.c: In function `fast_export_commit':\nvcs-svn/fast_export.c:42: warning: int format, uint32_t arg (arg 5)\nvcs-svn/fast_export.c:62: warning: int format, uint32_t arg (arg 2)\nvcs-svn/fast_export.c: In function `fast_export_blob':\nvcs-svn/fast_export.c:72: warning: int format, uint32_t arg (arg 2)\nvcs-svn/fast_export.c:72: warning: int format, uint32_t arg (arg 3)\n    CC vcs-svn/svndump.o\nvcs-svn/svndump.c: In function `svndump_read':\nvcs-svn/svndump.c:260: warning: int format, uint32_t arg (arg 3)\n\nIn order to suppress the warnings we use the C99 format specifier\nmacros PRIo32 and PRIu32 from <inttypes.h>.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nThe addition to git-compat-util.h is required in order to not break\nthe build on both MinGW and MSVC; there are other (better?) ways to\nfix this, but this was simple and seems to be in keeping with the\ncurrent code.\n\nATB,\nRamsay Jones\n\n git-compat-util.h     |    4 ++++\n vcs-svn/fast_export.c |    9 +++++----\n vcs-svn/svndump.c     |    2 +-\n 3 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 877096e..81883e7 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -160,6 +160,10 @@ extern char *gitbasename(char *);\n #define PRIx32 \"x\"\n #endif\n \n+#ifndef PRIo32\n+#define PRIo32 \"o\"\n+#endif\n+\n #ifndef PATH_SEP\n #define PATH_SEP ':'\n #endif\ndiff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c\nindex 256a052..6cfa256 100644\n--- a/vcs-svn/fast_export.c\n+++ b/vcs-svn/fast_export.c\n@@ -25,7 +25,7 @@ void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode,\n \t\t\tuint32_t mark)\n {\n \t/* Mode must be 100644, 100755, 120000, or 160000. */\n-\tprintf(\"M %06o :%d \", mode, mark);\n+\tprintf(\"M %06\"PRIo32\" :%\"PRIu32\" \", mode, mark);\n \tpool_print_seq(depth, path, '/', stdout);\n \tputchar('\\n');\n }\n@@ -38,7 +38,8 @@ void fast_export_commit(uint32_t revision, uint32_t author, char *log,\n \tif (!log)\n \t\tlog = \"\";\n \tif (~uuid && ~url) {\n-\t\tsnprintf(gitsvnline, MAX_GITSVN_LINE_LEN, \"\\n\\ngit-svn-id: %s@%d %s\\n\",\n+\t\tsnprintf(gitsvnline, MAX_GITSVN_LINE_LEN,\n+\t\t\t\t\"\\n\\ngit-svn-id: %s@%\"PRIu32\" %s\\n\",\n \t\t\t\t pool_fetch(url), revision, pool_fetch(uuid));\n \t} else {\n \t\t*gitsvnline = '\\0';\n@@ -59,7 +60,7 @@ void fast_export_commit(uint32_t revision, uint32_t author, char *log,\n \trepo_diff(revision - 1, revision);\n \tfputc('\\n', stdout);\n \n-\tprintf(\"progress Imported commit %d.\\n\\n\", revision);\n+\tprintf(\"progress Imported commit %\"PRIu32\".\\n\\n\", revision);\n }\n \n void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len)\n@@ -69,7 +70,7 @@ void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len)\n \t\tbuffer_skip_bytes(5);\n \t\tlen -= 5;\n \t}\n-\tprintf(\"blob\\nmark :%d\\ndata %d\\n\", mark, len);\n+\tprintf(\"blob\\nmark :%\"PRIu32\"\\ndata %\"PRIu32\"\\n\", mark, len);\n \tbuffer_copy_bytes(len);\n \tfputc('\\n', stdout);\n }\ndiff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c\nindex 630eeb5..53d0215 100644\n--- a/vcs-svn/svndump.c\n+++ b/vcs-svn/svndump.c\n@@ -257,7 +257,7 @@ void svndump_read(const char *url)\n \t\t\t\thandle_node();\n \t\t\t\tactive_ctx = REV_CTX;\n \t\t\t} else {\n-\t\t\t\tfprintf(stderr, \"Unexpected content length header: %d\\n\", len);\n+\t\t\t\tfprintf(stderr, \"Unexpected content length header: %\"PRIu32\"\\n\", len);\n \t\t\t\tbuffer_skip_bytes(len);\n \t\t\t}\n \t\t}\n-- \n1.7.2.1\n"},{"id":"150519","messageId":"AANLkTi=hhM64Jiph4ERzujyHgEo5C0vjc1oPhdpyxyUD@mail.gmail.com","threadId":"25056","inReplyTo":"4C891836.6070608@ramsay1.demon.co.uk","subject":"Re: [PATCH] vcs-svn: Fix some printf format compiler warnings","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-11T20:42:56Z","receivedAt":"2010-09-11T20:42:56Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Ramsay Jones wrote:\n\n> In order to suppress the warnings we use the C99 format specifier\n> macros PRIo32 and PRIu32 from <inttypes.h>.\n\nThanks.\n\n> The addition to git-compat-util.h is required in order to not break\n> the build on both MinGW and MSVC\n\nYep, looks sane. So for what it's worth:\n\n Acked-by: Jonathan Nieder <jrnieder@gmail.com>\n\nI see that David has already applied this to the svn-da tree, but it\nwould be good to have the fix in git, too.\n"}]}