Re: [PATCH 1/6] Fix some "printf format" warnings.
- From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
- Date
- Mar 13, 2007, 22:33 UTC
- Message-ID
- <45F726AE.2080609@ramsay1.demon.co.uk>
- In-Reply-To
- <45F55DC5.8060702@fs.ei.tum.de>
Simon 'corecode' Schubert wrote:
Show 24 quoted lines
> Ramsay Jones wrote:
>>>> - printf("%s%06o %s %d\t",
>>>> + printf("%s%06lo %s %d\t",
>>>> tag,
>>>> ntohl(ce->ce_mode),
>>> 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 ...
>
> shouldn't it be something like this?
>
> printf("%s%06"PRIo32" %s %d\t", tag, ntohl(ce->ce_mode), ...)
>
> that's the correct and allegedly portable way I guess.
>
> cheers
> simon
> Yes, that would work, but again I was trying not to depend on a C99 header file (namely <inttypes.h>).
I suppose I should just assume that git now requires these C99 headers!
Junio, what do you think about Simon's solution?
ATB,
Ramsay Jones