Fix warning in ggc-page about printf format

Andreas Jaeger aj@suse.de
Thu May 23 06:49:00 GMT 2002


Richard Henderson <rth@redhat.com> writes:

> On Tue, May 21, 2002 at 05:49:28PM +0200, Andreas Jaeger wrote:
>> If people prefer, I can use %lu and change also the rest of ggc-page
>> where size_t is casted to long.
>
> Please.

Here's a patch.  I also noticed that SCALE is unsigned long and output
as long, I've fixed this.

Bootstrapped/regtested on i686-linux-gnu.

Ok to commit?

Andreas

2002-05-22  Andreas Jaeger  <aj@suse.de>

	* ggc-page.c (alloc_page): Cast variables of type size_t to
	unsigned long, adjust printf format string.
	(ggc_alloc): Likewise.
	(ggc_print_statistics): Likewise.
	(ggc_print_statistics): Correct printf format string for SCALE to
	use unsigned long.


============================================================
Index: gcc/ggc-page.c
--- gcc/ggc-page.c	3 Mar 2002 14:07:19 -0000	1.49
+++ gcc/ggc-page.c	22 May 2002 06:37:08 -0000
@@ -732,8 +732,8 @@ alloc_page (order)
 
   if (GGC_DEBUG_LEVEL >= 2)
     fprintf (G.debug_file, 
-	     "Allocating page at %p, object size=%ld, data %p-%p\n",
-	     (PTR) entry, (long) OBJECT_SIZE (order), page,
+	     "Allocating page at %p, object size=%lu, data %p-%p\n",
+	     (PTR) entry, (unsigned long) OBJECT_SIZE (order), page,
 	     page + entry_size - 1);
 
   return entry;
@@ -954,8 +954,9 @@ ggc_alloc (size)
 
   if (GGC_DEBUG_LEVEL >= 3)
     fprintf (G.debug_file, 
-	     "Allocating object, requested size=%ld, actual=%ld at %p on %p\n",
-	     (long) size, (long) OBJECT_SIZE (order), result, (PTR) entry);
+	     "Allocating object, requested size=%lu, actual=%lu at %p on %p\n",
+	     (unsigned long) size, (unsigned long) OBJECT_SIZE (order), result,
+	     (PTR) entry);
 
   return result;
 }
@@ -1500,13 +1501,14 @@ 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, "%-5lu %10lu%c %10lu%c %10lu%c\n",
+	       (unsigned long) OBJECT_SIZE (i),
 	       SCALE (allocated), LABEL (allocated),
 	       SCALE (in_use), LABEL (in_use),
 	       SCALE (overhead), LABEL (overhead));
       total_overhead += overhead;
     }
-  fprintf (stderr, "%-5s %10ld%c %10ld%c %10ld%c\n", "Total",
+  fprintf (stderr, "%-5s %10lu%c %10lu%c %10lu%c\n", "Total",
 	   SCALE (G.bytes_mapped), LABEL (G.bytes_mapped),
 	   SCALE (G.allocated), LABEL(G.allocated),
 	   SCALE (total_overhead), LABEL (total_overhead));


-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj



More information about the Gcc-patches mailing list