Skip to contentSkip to conversation

svndump.c: Fix a printf format compiler warning

PATCH In review Ramsay Jones 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 svndump.c: Fix a printf format compiler warning

In particular, on systems that define uint32_t as an unsigned long, gcc complains as follows:

CC vcs-svn/svndump.o
vcs-svn/svndump.c: In function `svndump_read':
vcs-svn/svndump.c:215: warning: int format, uint32_t arg (arg 2)

In order to suppress the warning we use the C99 format specifier macro PRIu32 from <inttypes.h>.

---
 vcs-svn/svndump.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
vcs-svn/svndump.c +1 -1
index fa580e6..2ad2c30 100644
@@ -211,7 +211,7 @@ void svndump_read(const char *url)
 		if (key == keys.svn_fs_dump_format_version) {
 			dump_ctx.version = atoi(val);
 			if (dump_ctx.version > 2)
-				die("expected svn dump format version <= 2, found %d",
+				die("expected svn dump format version <= 2, found %"PRIu32,
 				    dump_ctx.version);
 		} else if (key == keys.uuid) {
 			dump_ctx.uuid = pool_intern(val);
Signature · 1 line
1.7.3
Acked-by on v1 1/1
#1 lore raw

vcs-svn/svndump.c void svndump_read(const char *url) · line 215

Quoted 9 lines · Ramsay Jones
vcs-svn/svndump.c +1 -1
@@ -211,7 +211,7 @@ void svndump_read(const char *url)
 		if (key == keys.svn_fs_dump_format_version) {
 			dump_ctx.version = atoi(val);
 			if (dump_ctx.version > 2)
-				die("expected svn dump format version <= 2, found %d",
+				die("expected svn dump format version <= 2, found %"PRIu32,
 				    dump_ctx.version);

I think we should just use "int", but that is a wider sweeping change for another time. Thanks.

Does gcc or sparse provide a warning that could have caught this mistake?

#2 lore raw
Quoted 13 lines · Jonathan Nieder

vcs-svn/svndump.c void svndump_read(const char *url) · line 215

Quoted 9 lines · Ramsay Jones
vcs-svn/svndump.c +1 -1
@@ -211,7 +211,7 @@ void svndump_read(const char *url)
 		if (key == keys.svn_fs_dump_format_version) {
 			dump_ctx.version = atoi(val);
 			if (dump_ctx.version > 2)
-				die("expected svn dump format version <= 2, found %d",
+				die("expected svn dump format version <= 2, found %"PRIu32,
 				    dump_ctx.version);

Thanks!

Quoted 5 lines

I think we should just use "int", but that is a wider sweeping change for another time. Thanks.

Does gcc or sparse provide a warning that could have caught this mistake?

None that I know of, no ... :(

ATB,
Ramsay Jones