Cygwin and git 1.5.1

Previous thread: [PATCH] allow git-update-index work on subprojects by Alex Riesen on Tuesday, April 10, 2007 - 6:39 am. (3 messages)

Next thread: Re: [PATCH 4/5] merge-recursive: handle D/F conflict case more carefully. by Junio C Hamano on Tuesday, April 10, 2007 - 11:20 am. (1 message)
From: Ramsay Jones
Date: Tuesday, April 10, 2007 - 10:39 am

Hi Junio,

I recently upgraded to 1.5.1, via tarball as usual, without much problem.
The only problem being the "printf format warnings" issue, which prevents
me building with -Werror.

I have included, below, an updated version of my patch from the 1.5.0 series.
We agreed last time that this patch is not the correct solution to this
problem in general (but it works on cygwin!), so this is *not* intended
for submission. I just wanted to document the problem. As before, I don't
really have a solution; I suppose I will just have to carry this patch
forward with each release - no big deal.

Note that the patch has grown larger. This is due to the increased use of
uint32_t (in combination with printf/die/error etc).
I guess not many others use -Werror to build on cygwin! ;-)

All the best,

Ramsay Jones

--- >8 ---
 From b2610fc65e42cd6a9acadb20343bddee7c1e3cec Mon Sep 17 00:00:00 2001
From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date: Mon, 9 Apr 2007 16:41:43 +0100
Subject: [PATCH] Fix some "printf format" warnings.


Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
  builtin-ls-files.c       |    2 +-
  builtin-pack-objects.c   |   20 ++++++++++----------
  builtin-unpack-objects.c |    2 +-
  fetch-pack.c             |    2 +-
  index-pack.c             |    2 +-
  merge-index.c            |    2 +-
  pack-check.c             |    2 +-
  read-cache.c             |    2 +-
  receive-pack.c           |    2 +-
  sha1_file.c              |    6 +++---
  unpack-trees.c           |    2 +-
  11 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 4e1d5af..310952a 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -193,7 +193,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
  		putchar(line_terminator);
  	}
  	else {
-		printf("%s%06o %s %d\t",
+		printf("%s%06lo %s %d\t",
  		       tag,
  		       ntohl(ce->ce_mode),
  		       abbrev ? ...
From: H. Peter Anvin
Date: Tuesday, April 10, 2007 - 3:44 pm

The excruciatingly correct way to do this is to use the macros defined 
in <inttypes.h>, so for uint32_t one should use %"PRNu32" instead of %u, 
for example.

	-hpa
-

From: Ramsay Jones
Date: Saturday, April 14, 2007 - 10:21 am

Yes, that would work. However, I rejected this solution last time, because
I did not want to add a dependency on the C99 header files.
Having said that, that ship has probably sailed ... ;-)

Maybe I will rework the patch to see how it looks. (I suspect that, while
it will be better than sprinkling casts about the place, it will probably
look quite ugly ;-P)

All the best,

Ramsay Jones


-

From: H. Peter Anvin
Date: Saturday, April 14, 2007 - 10:53 am

If you're using uint32_t and similar types, well, then, you're using 
<inttypes.h>.  Now, <inttypes.h> can be written up for an old compiler 
fairly easily.

	-hpa
-

Previous thread: [PATCH] allow git-update-index work on subprojects by Alex Riesen on Tuesday, April 10, 2007 - 6:39 am. (3 messages)

Next thread: Re: [PATCH 4/5] merge-recursive: handle D/F conflict case more carefully. by Junio C Hamano on Tuesday, April 10, 2007 - 11:20 am. (1 message)