threads / patch / 31286

patchfast_export.c: Fix a compiler warning

Subject: [PATCH] fast_export.c: Fix a compiler warning

## tl;dr

4 messages between Aug 19, 2012 and Aug 21, 2012. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Ramsay Jones· Aug 19, 2012, 15:29 UTC · lore
In particular, gcc complains thus:
        CC vcs-svn/fast_export.o
    vcs-svn/fast_export.c: In function 'fast_export_begin_note':
    vcs-svn/fast_export.c:77: warning: long long unsigned int format, \
        different type arg (arg 2)

In order to fix the warning, we cast the second size_t argument in the call to printf to uintmax_t.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
Hi Florian,

If you need to re-roll your patches in the 'fa/remote-svn' branch, could you please squash this fix into them. [This was implemented on top of commit 2ce959ba, but you will probably want to make the equivalent change to commit d319a37c ("Create a note for every imported commit containing svn metadata", 17-08-2012) instead. Note that, because of the context lines in the patch, it won't apply as-is.]

Thanks!

ATB, Ramsay Jones

 vcs-svn/fast_export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to vcs-svn/fast_export.c +1 −1
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
index c780d32..dd09c7d 100644
--- a/vcs-svn/fast_export.c
+++ b/vcs-svn/fast_export.c
@@ -74,7 +74,7 @@ void fast_export_begin_note(uint32_t revision, const char *author,
 	size_t loglen = strlen(log);
 	printf("commit %s\n", note_ref);
 	printf("committer %s <%s@%s> %ld +0000\n", author, author, "local", timestamp);
-	printf("data %"PRIuMAX"\n", loglen);
+	printf("data %"PRIuMAX"\n", (uintmax_t) loglen);
 	fwrite(log, loglen, 1, stdout);
 	if (firstnote) {
 		if (revision > 1)
-- 
1.7.11.2
Florian Achleitner· Aug 20, 2012, 06:19 UTC · re: Ramsay Jones · lore

Re: [PATCH] fast_export.c: Fix a compiler warning

On Sunday 19 August 2012 16:29:02 Ramsay Jones wrote:
Show 21 quoted lines
> In particular, gcc complains thus:
> 
>         CC vcs-svn/fast_export.o
>     vcs-svn/fast_export.c: In function 'fast_export_begin_note':
>     vcs-svn/fast_export.c:77: warning: long long unsigned int format, \
>         different type arg (arg 2)
> 
> In order to fix the warning, we cast the second size_t argument in
> the call to printf to uintmax_t.
> 
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> ---
> 
> Hi Florian,
> 
> If you need to re-roll your patches in the 'fa/remote-svn' branch, could
> you please squash this fix into them. [This was implemented on top of
> commit 2ce959ba, but you will probably want to make the equivalent change
> to commit d319a37c ("Create a note for every imported commit containing
> svn metadata", 17-08-2012) instead. Note that, because of the context
> lines in the patch, it won't apply as-is.]

Ok, I'll add it to the next version. This warning only occurs when building for 32bit, thus I never saw it. There would be a format flag for printf that sprecifies the platform's size_t integer type: "z". Probalby we should use it instead? I don't know how widely supported it is.

Show 5 quoted lines
> 
> Thanks!
> 
> ATB,
> Ramsay Jones

Thanks, Florian

Show 17 quoted lines
> 
>  vcs-svn/fast_export.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
> index c780d32..dd09c7d 100644
> --- a/vcs-svn/fast_export.c
> +++ b/vcs-svn/fast_export.c
> @@ -74,7 +74,7 @@ void fast_export_begin_note(uint32_t revision, const char
> *author, size_t loglen = strlen(log);
>  	printf("commit %s\n", note_ref);
>  	printf("committer %s <%s@%s> %ld +0000\n", author, author, "local",
> timestamp); -	printf("data %"PRIuMAX"\n", loglen);
> +	printf("data %"PRIuMAX"\n", (uintmax_t) loglen);
>  	fwrite(log, loglen, 1, stdout);
>  	if (firstnote) {
>  		if (revision > 1)
Junio C Hamano· Aug 20, 2012, 06:50 UTC · re: Florian Achleitner · lore

Re: [PATCH] fast_export.c: Fix a compiler warning

Florian Achleitner <florian.achleitner.2.6.31@gmail.com> writes:
Show 10 quoted lines
>> If you need to re-roll your patches in the 'fa/remote-svn' branch, could
>> you please squash this fix into them. [This was implemented on top of
>> commit 2ce959ba, but you will probably want to make the equivalent change
>> to commit d319a37c ("Create a note for every imported commit containing
>> svn metadata", 17-08-2012) instead. Note that, because of the context
>> lines in the patch, it won't apply as-is.]
>
> Ok, I'll add it to the next version. This warning only occurs when building 
> for 32bit, thus I never saw it. There would be a format flag for printf that 
> sprecifies the platform's size_t integer type: "z". 

Yeah, I also queued 05ce866 (fixup: add missing cast to vcs-svn/fast_export.c, 2012-08-18) on top of your series before pushing 'pu' out yesterday. Have you had a chance to look at these fixups? There are others you would find in my tree, including minor log message typofixes.

Ramsay Jones· Aug 21, 2012, 18:58 UTC · re: Florian Achleitner · lore

Re: [PATCH] fast_export.c: Fix a compiler warning

Florian Achleitner wrote:
> On Sunday 19 August 2012 16:29:02 Ramsay Jones wrote:
> Ok, I'll add it to the next version. This warning only occurs when building 
> for 32bit, thus I never saw it. There would be a format flag for printf that 
> sprecifies the platform's size_t integer type: "z". 
> Probalby we should use it instead? I don't know how widely supported it is.

The git codebase is actually moving in the other direction! :-D I think the last "%z" modifier was removed by commit 28bd70d8 ("unbreak and eliminate NO_C99_FORMAT", 16-03-2011).

ATB, Ramsay Jones

← back to recent threads