git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5/5] ewah_bitmap.c: Fix printf format warnings on MinGW
@ 2013-11-07 22:12 Ramsay Jones
  2013-11-07 23:01 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Ramsay Jones @ 2013-11-07 22:12 UTC (permalink / raw)
  To: Jeff King
  Cc: Vicent Marti, Junio C Hamano, Torsten Bögershausen,
	GIT Mailing-list


On MinGW, gcc complains as follows:

        CC ewah/ewah_bitmap.o
    ewah/ewah_bitmap.c: In function 'ewah_dump':
    ewah/ewah_bitmap.c:389: warning: unknown conversion type \
        character 'z' in format
    ewah/ewah_bitmap.c:389: warning: unknown conversion type \
        character 'z' in format
    ewah/ewah_bitmap.c:389: warning: too many arguments for format
    ewah/ewah_bitmap.c:392: warning: unknown conversion type \
        character 'l' in format
    ewah/ewah_bitmap.c:392: warning: too many arguments for format

In order to suppress the warnings, use the PRIuMAX and PRIx64 macros
from the <inttypes.h> header file.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
 ewah/ewah_bitmap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c
index 625f5a6..1e363b9 100644
--- a/ewah/ewah_bitmap.c
+++ b/ewah/ewah_bitmap.c
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <stdio.h>
+#include <inttypes.h>
 
 #include "ewok.h"
 #include "ewok_rlw.h"
@@ -386,10 +387,11 @@ void ewah_iterator_init(struct ewah_iterator *it, struct ewah_bitmap *parent)
 void ewah_dump(struct ewah_bitmap *self)
 {
 	size_t i;
-	fprintf(stderr, "%zu bits | %zu words | ", self->bit_size, self->buffer_size);
+	fprintf(stderr, "%"PRIuMAX" bits | %"PRIuMAX" words | ",
+		(uintmax_t)self->bit_size, (uintmax_t)self->buffer_size);
 
 	for (i = 0; i < self->buffer_size; ++i)
-		fprintf(stderr, "%016llx ", (unsigned long long)self->buffer[i]);
+		fprintf(stderr, "%016"PRIx64" ", (unsigned long long)self->buffer[i]);
 
 	fprintf(stderr, "\n");
 }
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5/5] ewah_bitmap.c: Fix printf format warnings on MinGW
  2013-11-07 22:12 [PATCH 5/5] ewah_bitmap.c: Fix printf format warnings on MinGW Ramsay Jones
@ 2013-11-07 23:01 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2013-11-07 23:01 UTC (permalink / raw)
  To: Ramsay Jones
  Cc: Jeff King, Vicent Marti, Torsten Bögershausen,
	GIT Mailing-list

Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:

> On MinGW, gcc complains as follows:
>
>         CC ewah/ewah_bitmap.o
>     ewah/ewah_bitmap.c: In function 'ewah_dump':
>     ewah/ewah_bitmap.c:389: warning: unknown conversion type \
>         character 'z' in format
>     ewah/ewah_bitmap.c:389: warning: unknown conversion type \
>         character 'z' in format
>     ewah/ewah_bitmap.c:389: warning: too many arguments for format
>     ewah/ewah_bitmap.c:392: warning: unknown conversion type \
>         character 'l' in format
>     ewah/ewah_bitmap.c:392: warning: too many arguments for format
>
> In order to suppress the warnings, use the PRIuMAX and PRIx64 macros
> from the <inttypes.h> header file.

Good; it is in line with 28bd70d8 (unbreak and eliminate
NO_C99_FORMAT, 2011-03-16) and 3efb1f34 (Check for PRIuMAX rather
than NO_C99_FORMAT in fast-import.c., 2007-02-20).

Thanks.


> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> ---
>  ewah/ewah_bitmap.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c
> index 625f5a6..1e363b9 100644
> --- a/ewah/ewah_bitmap.c
> +++ b/ewah/ewah_bitmap.c
> @@ -22,6 +22,7 @@
>  #include <unistd.h>
>  #include <string.h>
>  #include <stdio.h>
> +#include <inttypes.h>
>  
>  #include "ewok.h"
>  #include "ewok_rlw.h"
> @@ -386,10 +387,11 @@ void ewah_iterator_init(struct ewah_iterator *it, struct ewah_bitmap *parent)
>  void ewah_dump(struct ewah_bitmap *self)
>  {
>  	size_t i;
> -	fprintf(stderr, "%zu bits | %zu words | ", self->bit_size, self->buffer_size);
> +	fprintf(stderr, "%"PRIuMAX" bits | %"PRIuMAX" words | ",
> +		(uintmax_t)self->bit_size, (uintmax_t)self->buffer_size);
>  
>  	for (i = 0; i < self->buffer_size; ++i)
> -		fprintf(stderr, "%016llx ", (unsigned long long)self->buffer[i]);
> +		fprintf(stderr, "%016"PRIx64" ", (unsigned long long)self->buffer[i]);
>  
>  	fprintf(stderr, "\n");
>  }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-07 23:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-07 22:12 [PATCH 5/5] ewah_bitmap.c: Fix printf format warnings on MinGW Ramsay Jones
2013-11-07 23:01 ` Junio C Hamano

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).