sha1_file.c: Fix size_t related printf format warnings
The old way of fixing warnings did not succeed on MinGW. MinGW does not support C99 printf format strings for size_t [1]. But gcc on MinGW issues warnings if C99 printf format is not used. Hence, the old stragegy to avoid warnings fails. [1] http://www.mingw.org/MinGWiki/index.php/C99 This commits passes arguments of type size_t through a tiny helper functions that casts to the type expected by the format string. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Steffen Prohaska committed
Nov 21, 2007 at 21:27 UTC
9e42d6a1c53dadd409fab11cc76e0eba9ec15365
1 file changed
+6
-4
sha1_file.c
+6
-4
@@ -25,8 +25,10 @@
25
26
#ifdef NO_C99_FORMAT
27
#define SZ_FMT "lu"
28
+static unsigned long sz_fmt(size_t s) { return (unsigned long)s; }
29
#else
30
#define SZ_FMT "zu"
31
+static size_t sz_fmt(size_t s) { return s; }
32
#endif
33
34
const unsigned char null_sha1[20];
@@ -423,9 +425,9 @@ void pack_report(void)
425
"pack_report: getpagesize() = %10" SZ_FMT "\n"
426
"pack_report: core.packedGitWindowSize = %10" SZ_FMT "\n"
427
"pack_report: core.packedGitLimit = %10" SZ_FMT "\n",
426
- (size_t) getpagesize(),
427
- packed_git_window_size,
428
- packed_git_limit);
428
+ sz_fmt(getpagesize()),
429
+ sz_fmt(packed_git_window_size),
430
+ sz_fmt(packed_git_limit));
431
fprintf(stderr,
432
"pack_report: pack_used_ctr = %10u\n"
433
"pack_report: pack_mmap_calls = %10u\n"
@@ -435,7 +437,7 @@ void pack_report(void)
437
pack_used_ctr,
438
pack_mmap_calls,
439
pack_open_windows, peak_pack_open_windows,
438
- pack_mapped, peak_pack_mapped);
440
+ sz_fmt(pack_mapped), sz_fmt(peak_pack_mapped));
441
}
442
443
static int check_packed_git_idx(const char *path, struct packed_git *p)