This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch for pedantic format warnings


This patch fixes the pedantic warnings generated by my patch

http://gcc.gnu.org/ml/gcc-patches/2000-07/msg00704.html

and shown up by a bootstrap on i686-pc-linux-gnu.

Pointers (other than char * or void *) are cast to PTR for formatting
with %p or HOST_PTR_PRINTF.  (Why do some places use HOST_PTR_PRINTF,
and others %p explicitly?)  In addition, a signed/unsigned fix is made
in libiberty.

This patch may be applied independently of the format checking patch.

Bootstrapped with no regressions on i686-pc-linux-gnu.

libiberty/ChangeLog:
2000-07-18  Joseph S. Myers  <jsm28@cam.ac.uk>

	* cplus-dem.c (demangle_fund_type): Make 'dec' an unsigned int,
	and print it with %u.

gcc/ChangeLog:
2000-07-18  Joseph S. Myers  <jsm28@cam.ac.uk>

	* bitmap.c (debug_bitmap_file): Cast pointers to PTR for printing
	with %p.
	* ggc-page.c (debug_print_page_list, alloc_page, free_page,
	ggc_alloc): Likewise.
	* bb-reorder.c (dump_scope_forest_1): Likewise.

--- libiberty/cplus-dem.c	Fri Jul  7 13:50:49 2000
+++ libiberty/cplus-dem.c.new	Tue Jul 18 23:08:40 2000
@@ -3399,7 +3399,7 @@ demangle_fund_type (work, mangled, resul
   int done = 0;
   int success = 1;
   char buf[10];
-  int dec = 0;
+  unsigned int dec = 0;
   string btype;
   type_kind_t tk = tk_integral;
 
@@ -3543,7 +3543,7 @@ demangle_fund_type (work, mangled, resul
 	  *mangled += min (strlen (*mangled), 2);
 	}
       sscanf (buf, "%x", &dec);
-      sprintf (buf, "int%i_t", dec);
+      sprintf (buf, "int%u_t", dec);
       APPEND_BLANK (result);
       string_append (result, buf);
       break;
--- gcc/bitmap.c	Fri May 19 22:27:27 2000
+++ gcc/bitmap.c.new	Tue Jul 18 23:01:38 2000
@@ -596,9 +596,9 @@ debug_bitmap_file (file, head)
   bitmap_element *ptr;
 
   fprintf (file, "\nfirst = ");
-  fprintf (file, HOST_PTR_PRINTF, head->first);
+  fprintf (file, HOST_PTR_PRINTF, (PTR) head->first);
   fprintf (file, " current = ");
-  fprintf (file, HOST_PTR_PRINTF, head->current);
+  fprintf (file, HOST_PTR_PRINTF, (PTR) head->current);
   fprintf (file, " indx = %u\n", head->indx);
 
   for (ptr = head->first; ptr; ptr = ptr->next)
@@ -606,11 +606,11 @@ debug_bitmap_file (file, head)
       int i, j, col = 26;
 
       fprintf (file, "\t");
-      fprintf (file, HOST_PTR_PRINTF, ptr);
+      fprintf (file, HOST_PTR_PRINTF, (PTR) ptr);
       fprintf (file, " next = ");
-      fprintf (file, HOST_PTR_PRINTF, ptr->next);
+      fprintf (file, HOST_PTR_PRINTF, (PTR) ptr->next);
       fprintf (file, " prev = ");
-      fprintf (file, HOST_PTR_PRINTF, ptr->prev);
+      fprintf (file, HOST_PTR_PRINTF, (PTR) ptr->prev);
       fprintf (file, " indx = %u\n\t\tbits = {", ptr->indx);
 
       for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
--- gcc/ggc-page.c	Fri Jun  9 21:47:38 2000
+++ gcc/ggc-page.c.new	Tue Jul 18 23:05:22 2000
@@ -386,11 +386,13 @@ debug_print_page_list (order)
      int order;
 {
   page_entry *p;
-  printf ("Head=%p, Tail=%p:\n", G.pages[order], G.page_tails[order]);
+  printf ("Head=%p, Tail=%p:\n", (PTR) G.pages[order],
+	  (PTR) G.page_tails[order]);
   p = G.pages[order];
   while (p != NULL)
     {
-      printf ("%p(%1d|%3d) -> ", p, p->context_depth, p->num_free_objects);
+      printf ("%p(%1d|%3d) -> ", (PTR) p, p->context_depth,
+	      p->num_free_objects);
       p = p->next;
     }
   printf ("NULL\n");
@@ -504,8 +506,8 @@ alloc_page (order)
 
   if (GGC_DEBUG_LEVEL >= 2)
     fprintf (G.debug_file, 
-	     "Allocating page at %p, object size=%d, data %p-%p\n", entry,
-	     1 << order, page, page + entry_size - 1);
+	     "Allocating page at %p, object size=%d, data %p-%p\n",
+	     (PTR) entry, 1 << order, page, page + entry_size - 1);
 
   return entry;
 }
@@ -518,7 +520,7 @@ free_page (entry)
 {
   if (GGC_DEBUG_LEVEL >= 2)
     fprintf (G.debug_file, 
-	     "Deallocating page at %p, data %p-%p\n", entry,
+	     "Deallocating page at %p, data %p-%p\n", (PTR) entry,
 	     entry->page, entry->page + entry->bytes - 1);
 
   set_page_table_entry (entry->page, NULL);
@@ -714,7 +716,7 @@ ggc_alloc (size)
   if (GGC_DEBUG_LEVEL >= 3)
     fprintf (G.debug_file, 
 	     "Allocating object, requested size=%d, actual=%d at %p on %p\n",
-	     (int) size, 1 << order, result, entry);
+	     (int) size, 1 << order, result, (PTR) entry);
 
   return result;
 }
--- gcc/bb-reorder.c	Sun Jun 11 04:29:46 2000
+++ gcc/bb-reorder.c.new	Tue Jul 18 23:06:09 2000
@@ -1318,7 +1318,7 @@ dump_scope_forest_1 (s, indent)
 
   fprintf (stderr, "%*s", indent, "");
   fprintf (stderr, "{ level %d (block %p)\n", s->level,
-	   NOTE_BLOCK (s->note_beg));
+	   (PTR) NOTE_BLOCK (s->note_beg));
 
   fprintf (stderr, "%*s%s", indent, "", "bbs:");
   for (i = 0; i < s->num_bbs; i++)

-- 
Joseph S. Myers
jsm28@cam.ac.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]