From: Steffen Prohaska <prohaska@zib.de>
To: git@vger.kernel.org
Cc: Steffen Prohaska <prohaska@zib.de>
Subject: [PATCH 1/3] sha1_file.c: Fix size_t related printf format warnings
Date: Wed, 21 Nov 2007 21:27:19 +0100 [thread overview]
Message-ID: <11956768412804-git-send-email-prohaska@zib.de> (raw)
In-Reply-To: <11956768414090-git-send-email-prohaska@zib.de>
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>
---
sha1_file.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index f007874..4f68e53 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -25,8 +25,10 @@
#ifdef NO_C99_FORMAT
#define SZ_FMT "lu"
+static unsigned long sz_fmt(size_t s) { return (unsigned long)s; }
#else
#define SZ_FMT "zu"
+static size_t sz_fmt(size_t s) { return s; }
#endif
const unsigned char null_sha1[20];
@@ -423,9 +425,9 @@ void pack_report(void)
"pack_report: getpagesize() = %10" SZ_FMT "\n"
"pack_report: core.packedGitWindowSize = %10" SZ_FMT "\n"
"pack_report: core.packedGitLimit = %10" SZ_FMT "\n",
- (size_t) getpagesize(),
- packed_git_window_size,
- packed_git_limit);
+ sz_fmt(getpagesize()),
+ sz_fmt(packed_git_window_size),
+ sz_fmt(packed_git_limit));
fprintf(stderr,
"pack_report: pack_used_ctr = %10u\n"
"pack_report: pack_mmap_calls = %10u\n"
@@ -435,7 +437,7 @@ void pack_report(void)
pack_used_ctr,
pack_mmap_calls,
pack_open_windows, peak_pack_open_windows,
- pack_mapped, peak_pack_mapped);
+ sz_fmt(pack_mapped), sz_fmt(peak_pack_mapped));
}
static int check_packed_git_idx(const char *path, struct packed_git *p)
--
1.5.3.5.750.g8692
next prev parent reply other threads:[~2007-11-21 20:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-21 20:27 [PATCH 0/3] msysgit fallout Steffen Prohaska
2007-11-21 20:27 ` Steffen Prohaska [this message]
2007-11-21 20:27 ` [PATCH 2/3] builtin-init-db: use get_git_dir() instead of getenv() Steffen Prohaska
2007-11-21 20:27 ` [PATCH 3/3] Replace setenv(GIT_DIR_ENVIRONMENT, ...) with set_git_dir() Steffen Prohaska
2007-11-22 1:22 ` Johannes Schindelin
2007-11-22 2:34 ` Junio C Hamano
2007-11-22 6:13 ` Steffen Prohaska
2007-11-22 7:52 ` Junio C Hamano
2007-11-22 8:31 ` Steffen Prohaska
2007-11-22 9:58 ` Johannes Sixt
2007-11-22 17:56 ` Steffen Prohaska
2007-11-22 22:09 ` Johannes Schindelin
2008-01-01 18:52 ` Steffen Prohaska
2008-01-03 4:07 ` Dmitry Kakurin
2008-01-03 6:02 ` Steffen Prohaska
2008-01-03 6:26 ` Dmitry Kakurin
2008-01-03 7:53 ` Steffen Prohaska
2007-11-22 7:29 ` Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11956768412804-git-send-email-prohaska@zib.de \
--to=prohaska@zib.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).