This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix warning in ggc-page about printf format
- From: Andreas Jaeger <aj at suse dot de>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 21 May 2002 17:49:28 +0200
- Subject: Re: Fix warning in ggc-page about printf format
- References: <hoy9edmz26.fsf@gee.suse.de> <jeoff9v713.fsf@sykes.suse.de>
Andreas Schwab <schwab@suse.de> writes:
> Andreas Jaeger <aj@suse.de> writes:
>
> |> On a 64-bit host I get this warning:
> |> /sources/gcc/gcc/gcc/ggc-page.c:1506: warning: int format, different type arg (arg 3)
> |>
> |> The problem is that we're printing an entry of this array:
> |> static size_t object_size_table[NUM_ORDERS];
> |>
> |> with "%-5d".
> |>
> |> Here's a patch. Bootstrapped/regtested on i686-linux-gnu.
> |>
> |> Ok to commit?
> |>
> |> Andreas
> |>
> |> 2002-05-21 Andreas Jaeger <aj@suse.de>
> |>
> |> * ggc-page.c (ggc_print_statistics): Avoid printf mismatch warnings.
> |>
> |>
> |> ============================================================
> |> Index: gcc/ggc-page.c
> |> --- gcc/ggc-page.c 3 Mar 2002 14:07:19 -0000 1.49
> |> +++ gcc/ggc-page.c 21 May 2002 07:17:23 -0000
> |> @@ -1500,7 +1500,7 @@ ggc_print_statistics ()
> |> overhead += (sizeof (page_entry) - sizeof (long)
> |> + BITMAP_SIZE (OBJECTS_PER_PAGE (i) + 1));
> |> }
> |> - fprintf (stderr, "%-5d %10ld%c %10ld%c %10ld%c\n", OBJECT_SIZE (i),
> |> + fprintf (stderr, "%-5ld %10ld%c %10ld%c %10ld%c\n", (long)OBJECT_SIZE (i),
>
> IMHO this should rather use %lu and unsigned long, since size_t is an
> unsigned type.
I thought about this - and checked other such uses in this file.
If people prefer, I can use %lu and change also the rest of ggc-page
where size_t is casted to long.
Andreas
P.S. Redirected to gcc-patches, I fear I used the wrong email address
this morning :-(
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj