This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] remote-e7000.c warnings
Andrew Cagney writes:
> > 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.
>
>
> This is me be paranoid :-) If you can find someone to test it then
> good, if not, we might as well just bite the bullet and let it go in
> anway :-/ It certainly falls under:
>
> ``All maintainers can make mechanical (params, spelling, indentation,
> multi-arch, -W..., ....) changes to ``maintenance only'' targets.
> Please sanity check the change by compiling with one of the listed
> targets.''
>
>
> > - sprintf (buf, ".ER%d %lx\r", regno, read_register (regno));
> > + sprintf (buf, ".ER%d %lx\r", regno, (long) read_register (regno));
>
>
> To think out loud, is:
>
> sprintf (buf, ".ER%d %s\r", regno, phex_nz (read_register (regno), 0);
>
> more portable? I suspect I had that in mind and hence the comment.
>
> enjoy,
> Andrew
Ok, then. I checked in the following:
2001-07-13 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.
* Makefile.in (remote-e7000.o): Can now compile with -Werror.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.95
diff -u -p -r1.95 Makefile.in
--- Makefile.in 2001/07/10 23:08:12 1.95
+++ Makefile.in 2001/07/13 20:00:39
@@ -1837,13 +1837,8 @@ remote-bug.o: remote-bug.c $(defs_h) $(g
$(inferior_h) target.h terminal.h $(remote_utils_h) $(gdb_string_h) \
$(regcache_h)
-# 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.
remote-e7000.o: remote-e7000.c $(defs_h) $(gdbcore_h) target.h \
serial.h $(gdb_string_h) $(regcache_h)
- $(CC) -c $(INTERNAL_WARN_CFLAGS) $(NO_WERROR_CFLAGS) $<
remote-eb.o: remote-eb.c $(srcdir)/config/a29k/tm-a29k.h \
$(defs_h) $(gdbcore_h) $(inferior_h) symfile.h target.h terminal.h \
Index: remote-e7000.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-e7000.c,v
retrieving revision 1.23
diff -u -p -r1.23 remote-e7000.c
--- remote-e7000.c 2001/07/11 17:52:32 1.23
+++ remote-e7000.c 2001/07/13 20:00:40
@@ -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 %s\r", regno, phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
else if (regno == PC_REGNUM)
{
- sprintf (buf, ".PC %lx\r", read_register (regno));
+ sprintf (buf, ".PC %s\r", phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
#ifdef CCR_REGNUM
else if (regno == CCR_REGNUM)
{
- sprintf (buf, ".CCR %lx\r", read_register (regno));
+ sprintf (buf, ".CCR %s\r", phex_nz (read_register (regno), 0));
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 %s\r", phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
else if (regno == SR_REGNUM)
{
- sprintf (buf, ".SR %lx\r", read_register (regno));
+ sprintf (buf, ".SR %s\r", phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
else if (regno == PR_REGNUM)
{
- sprintf (buf, ".PR %lx\r", read_register (regno));
+ sprintf (buf, ".PR %s\r", phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
else if (regno == GBR_REGNUM)
{
- sprintf (buf, ".GBR %lx\r", read_register (regno));
+ sprintf (buf, ".GBR %s\r", phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
else if (regno == VBR_REGNUM)
{
- sprintf (buf, ".VBR %lx\r", read_register (regno));
+ sprintf (buf, ".VBR %s\r", phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
else if (regno == MACH_REGNUM)
{
- sprintf (buf, ".MACH %lx\r", read_register (regno));
+ sprintf (buf, ".MACH %s\r", phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
else if (regno == MACL_REGNUM)
{
- sprintf (buf, ".MACL %lx\r", read_register (regno));
+ sprintf (buf, ".MACL %s\r", phex_nz (read_register (regno), 0));
puts_e7000debug (buf);
}
else
{
- sprintf (buf, ".R%d %lx\r", regno, read_register (regno));
+ sprintf (buf, ".R%d %s\r", regno, phex_nz (read_register (regno), 0));
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 %s\r", phex_nz (read_register (PC_REGNUM), 0));
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 */