[RFA] remote-e7000.c warnings

Elena Zannoni ezannoni@cygnus.com
Wed Jul 11 18:32:00 GMT 2001


This patch removes warnings when building remote-e7000.c.  (On Linux
7.0) Since this file gets build with target=sh-elf, I was getting
tired of all the warnings on the screen.
But then I saw the FIXME in the Makefile, so I am not sure what to do.
# FIXME: For the SH target, remote-e7000 contains numerous -Wformat
# warnings.  Since the fixes involve modifications to the code that
# handles the SH remote protocol the changes need to be tested against
# an SH board before they can be committed. cagney 1999-09-01.

Ideas?
Can anybody test this with a real connection?

Here is the patch anyway.

Elena

2001-07-11  Elena Zannoni  <ezannoni@redhat.com>

	* remote-e7000.c (fetch_regs_from_dump): If register set is null,
	generate an internal error.
	(e7000_fetch_registers): Initialize variable 'wanted'.
	(e7000_wait): Initialize variable 'wanted_nopc'.
	(e7000_store_register): Fix sprintf compiler warnings.
	(sub2_from_pc): Ditto.
	(e7000_open): Close the descriptor, not the name.
	(e7000_load): Fix compiler warnings.
	(sub2_from_pc): Ditto.


Index: remote-e7000.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-e7000.c,v
retrieving revision 1.22
diff -u -p -r1.22 remote-e7000.c
--- remote-e7000.c	2001/06/10 16:25:51	1.22
+++ remote-e7000.c	2001/07/12 01:28:22
@@ -652,7 +652,7 @@ e7000_open (char *args, int from_tty)
 
   if (SERIAL_SETBAUDRATE (e7000_desc, baudrate))
     {
-      SERIAL_CLOSE (dev_name);
+      SERIAL_CLOSE (e7000_desc);
       perror_with_name (dev_name);
     }
   SERIAL_RAW (e7000_desc);
@@ -789,6 +789,9 @@ fetch_regs_from_dump (int (*nextchar) ()
 
   int thischar = nextchar ();
 
+  if (want == NULL)
+    internal_error (__FILE__, __LINE__, "Register set not selected.");
+
   while (*want)
     {
       switch (*want)
@@ -891,7 +894,7 @@ static void
 e7000_fetch_registers (void)
 {
   int regno;
-  char *wanted;
+  char *wanted = NULL;
 
   puts_e7000debug ("R\r");
 
@@ -966,18 +969,18 @@ e7000_store_register (int regno)
     {
       if (regno <= 7)
 	{
-	  sprintf (buf, ".ER%d %lx\r", regno, read_register (regno));
+	  sprintf (buf, ".ER%d %lx\r", regno, (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
       else if (regno == PC_REGNUM)
 	{
-	  sprintf (buf, ".PC %lx\r", read_register (regno));
+	  sprintf (buf, ".PC %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
 #ifdef CCR_REGNUM
       else if (regno == CCR_REGNUM)
 	{
-	  sprintf (buf, ".CCR %lx\r", read_register (regno));
+	  sprintf (buf, ".CCR %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
 #endif
@@ -987,48 +990,48 @@ e7000_store_register (int regno)
     {
       if (regno == PC_REGNUM)
 	{
-	  sprintf (buf, ".PC %lx\r", read_register (regno));
+	  sprintf (buf, ".PC %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
 
       else if (regno == SR_REGNUM)
 	{
-	  sprintf (buf, ".SR %lx\r", read_register (regno));
+	  sprintf (buf, ".SR %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
 
       else if (regno ==  PR_REGNUM)
 	{
-	  sprintf (buf, ".PR %lx\r", read_register (regno));
+	  sprintf (buf, ".PR %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
 
       else if (regno == GBR_REGNUM)
 	{
-	  sprintf (buf, ".GBR %lx\r", read_register (regno));
+	  sprintf (buf, ".GBR %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
 
       else if (regno == VBR_REGNUM)
 	{
-	  sprintf (buf, ".VBR %lx\r", read_register (regno));
+	  sprintf (buf, ".VBR %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
 
       else if (regno == MACH_REGNUM)
 	{
-	  sprintf (buf, ".MACH %lx\r", read_register (regno));
+	  sprintf (buf, ".MACH %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
 
       else if (regno == MACL_REGNUM)
 	{
-	  sprintf (buf, ".MACL %lx\r", read_register (regno));
+	  sprintf (buf, ".MACL %lx\r", (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
       else
 	{
-	  sprintf (buf, ".R%d %lx\r", regno, read_register (regno));
+	  sprintf (buf, ".R%d %lx\r", regno, (long) read_register (regno));
 	  puts_e7000debug (buf);
 	}
     }
@@ -1570,10 +1573,10 @@ e7000_load (char *args, int from_tty)
 	  section_size = bfd_get_section_size_before_reloc (section);
 
 	  if (!quiet)
-	    printf_filtered ("[Loading section %s at 0x%x (%ud bytes)]\n",
+	    printf_filtered ("[Loading section %s at 0x%s (%s bytes)]\n",
 			     bfd_get_section_name (pbfd, section),
-			     section_address,
-			     section_size);
+			     paddr_nz (section_address),
+			     paddr_u (section_size));
 
 	  fptr = 0;
 
@@ -1647,7 +1650,7 @@ e7000_load (char *args, int from_tty)
       entry = bfd_get_start_address (pbfd);
 
       if (!quiet)
-	printf_unfiltered ("[Starting %s at 0x%x]\n", filename, entry);
+	printf_unfiltered ("[Starting %s at 0x%s]\n", filename, paddr_nz (entry));
 
 /*      start_routine (entry); */
     }
@@ -1965,7 +1968,7 @@ sub2_from_pc (void)
 			REGISTER_RAW_SIZE (PC_REGNUM),
 			read_register (PC_REGNUM) - 2);
   supply_register (PC_REGNUM, buf);
-  sprintf (buf2, ".PC %lx\r", read_register (PC_REGNUM));
+  sprintf (buf2, ".PC %lx\r", (long) read_register (PC_REGNUM));
   puts_e7000debug (buf2);
 }
 
@@ -1994,7 +1997,7 @@ e7000_wait (ptid_t ptid, struct target_w
   int running_count = 0;
   int had_sleep = 0;
   int loop = 1;
-  char *wanted_nopc;
+  char *wanted_nopc = NULL;
 
   /* Then echo chars until PC= string seen */
   gch ();			/* Drop cr */



More information about the Gdb-patches mailing list