All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
To: Junio C Hamano <junkio@cox.net>
Cc: GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH 1/6] Fix some "printf format" warnings.
Date: Sun, 04 Mar 2007 17:08:49 +0000	[thread overview]
Message-ID: <45EAFD21.6010002@ramsay1.demon.co.uk> (raw)
In-Reply-To: <7v4pp29eok.fsf@assigned-by-dhcp.cox.net>

Hi Junio,

Junio C Hamano wrote:
> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
>> diff --git a/builtin-ls-files.c b/builtin-ls-files.c
>> index ac89eb2..5c990a5 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 ? find_unique_abbrev(ce->sha1,abbrev)
> 
> I think the issue is ntohl() returns uint32_t, and this did not
> surface as an issue so far only because that type happens to be
> defined as 'unsigned int' on many systems.  Changing %o to %lo
> is shifting the breakage to other systems, isn't it?
> 
> I think we should do this instead:
> 
> 	printf("%s%06o %s %d\t", tag, (unsigned) ntohl(ce->ce_mode), ...
> 
> 

Oops, yes you are right.
(cygwin typedef's uint32_t as unsigned long.)

However, I would hate to add all those casts! Casts are not always evil, but
should be avoided if possible. Having said that, I don't see another solution ...
Hmmm, I dunno, your call ;-)

All the best,

Ramsay Jones

  reply	other threads:[~2007-03-04 18:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-03 18:28 [PATCH 1/6] Fix some "printf format" warnings Ramsay Jones
2007-03-03 21:53 ` Junio C Hamano
2007-03-04 17:08   ` Ramsay Jones [this message]
2007-03-12 14:03     ` Simon 'corecode' Schubert
2007-03-12 19:40       ` Junio C Hamano
2007-03-14 22:57         ` Ramsay Jones
2007-03-14 23:41           ` Junio C Hamano
2007-03-13 22:33       ` Ramsay Jones

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=45EAFD21.6010002@ramsay1.demon.co.uk \
    --to=ramsay@ramsay1.demon.co.uk \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.