Skip to content

Commit 5418d96

Browse files
Ramsay Jonesgitster
authored andcommitted
vcs-svn: Fix some printf format compiler warnings
In particular, on systems that define uint32_t as an unsigned long, gcc complains as follows: CC vcs-svn/fast_export.o vcs-svn/fast_export.c: In function `fast_export_modify': vcs-svn/fast_export.c:28: warning: unsigned int format, uint32_t arg (arg 2) vcs-svn/fast_export.c:28: warning: int format, uint32_t arg (arg 3) vcs-svn/fast_export.c: In function `fast_export_commit': vcs-svn/fast_export.c:42: warning: int format, uint32_t arg (arg 5) vcs-svn/fast_export.c:62: warning: int format, uint32_t arg (arg 2) vcs-svn/fast_export.c: In function `fast_export_blob': vcs-svn/fast_export.c:72: warning: int format, uint32_t arg (arg 2) vcs-svn/fast_export.c:72: warning: int format, uint32_t arg (arg 3) CC vcs-svn/svndump.o vcs-svn/svndump.c: In function `svndump_read': vcs-svn/svndump.c:260: warning: int format, uint32_t arg (arg 3) In order to suppress the warnings we use the C99 format specifier macros PRIo32 and PRIu32 from <inttypes.h>. Signed-off-by: Ramsay Jones <[email protected]> Acked-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b3a8ed commit 5418d96

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

git-compat-util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ extern char *gitbasename(char *);
160160
#define PRIx32 "x"
161161
#endif
162162

163+
#ifndef PRIo32
164+
#define PRIo32 "o"
165+
#endif
166+
163167
#ifndef PATH_SEP
164168
#define PATH_SEP ':'
165169
#endif

vcs-svn/fast_export.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode,
2525
uint32_t mark)
2626
{
2727
/* Mode must be 100644, 100755, 120000, or 160000. */
28-
printf("M %06o :%d ", mode, mark);
28+
printf("M %06"PRIo32" :%"PRIu32" ", mode, mark);
2929
pool_print_seq(depth, path, '/', stdout);
3030
putchar('\n');
3131
}
@@ -38,7 +38,8 @@ void fast_export_commit(uint32_t revision, uint32_t author, char *log,
3838
if (!log)
3939
log = "";
4040
if (~uuid && ~url) {
41-
snprintf(gitsvnline, MAX_GITSVN_LINE_LEN, "\n\ngit-svn-id: %s@%d %s\n",
41+
snprintf(gitsvnline, MAX_GITSVN_LINE_LEN,
42+
"\n\ngit-svn-id: %s@%"PRIu32" %s\n",
4243
pool_fetch(url), revision, pool_fetch(uuid));
4344
} else {
4445
*gitsvnline = '\0';
@@ -59,7 +60,7 @@ void fast_export_commit(uint32_t revision, uint32_t author, char *log,
5960
repo_diff(revision - 1, revision);
6061
fputc('\n', stdout);
6162

62-
printf("progress Imported commit %d.\n\n", revision);
63+
printf("progress Imported commit %"PRIu32".\n\n", revision);
6364
}
6465

6566
void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len)
@@ -69,7 +70,7 @@ void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len)
6970
buffer_skip_bytes(5);
7071
len -= 5;
7172
}
72-
printf("blob\nmark :%d\ndata %d\n", mark, len);
73+
printf("blob\nmark :%"PRIu32"\ndata %"PRIu32"\n", mark, len);
7374
buffer_copy_bytes(len);
7475
fputc('\n', stdout);
7576
}

vcs-svn/svndump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void svndump_read(const char *url)
257257
handle_node();
258258
active_ctx = REV_CTX;
259259
} else {
260-
fprintf(stderr, "Unexpected content length header: %d\n", len);
260+
fprintf(stderr, "Unexpected content length header: %"PRIu32"\n", len);
261261
buffer_skip_bytes(len);
262262
}
263263
}

0 commit comments

Comments
 (0)