This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix a couple of gdbserver build warnings


I'm seeing this:

 ../../../src/gdb/gdbserver/linux-low.c: In function 'fetch_register':
 ../../../src/gdb/gdbserver/linux-low.c:2226: warning: format not a string literal and no format arguments
 ../../../src/gdb/gdbserver/linux-low.c: In function 'usr_store_inferior_registers':
 ../../../src/gdb/gdbserver/linux-low.c:2307: warning: format not a string literal and no format arguments
	
I've applied this patch to fix it.

AFAICS, going back to revision 1.1 of linux-low.c, the code in
fetch_register never warned instead of erroring out, as the comment
claims, so, I'm just dropping the comment.  The goto and the return
after the error calls are unreacheable, since error longjmp's.

-- 
Pedro Alves

2010-03-15  Pedro Alves  <pedro@codesourcery.com>

	* linux-low.c (fetch_register): Avoid passing a non string literal
	format to `error'.
	(usr_store_inferior_registers): Ditto.

---
 gdb/gdbserver/linux-low.c |   21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

Index: src/gdb/gdbserver/linux-low.c
===================================================================
--- src.orig/gdb/gdbserver/linux-low.c	2010-03-15 00:24:14.000000000 +0000
+++ src/gdb/gdbserver/linux-low.c	2010-03-15 00:24:57.000000000 +0000
@@ -2217,23 +2217,13 @@ fetch_register (struct regcache *regcach
 		(PTRACE_ARG3_TYPE) (uintptr_t) regaddr, 0);
       regaddr += sizeof (PTRACE_XFER_TYPE);
       if (errno != 0)
-	{
-	  /* Warning, not error, in case we are attached; sometimes the
-	     kernel doesn't let us at the registers.  */
-	  char *err = strerror (errno);
-	  char *msg = alloca (strlen (err) + 128);
-	  sprintf (msg, "reading register %d: %s", regno, err);
-	  error (msg);
-	  goto error_exit;
-	}
+	error ("reading register %d: %s", regno, strerror (errno));
     }
 
   if (the_low_target.supply_ptrace_register)
     the_low_target.supply_ptrace_register (regcache, regno, buf);
   else
     supply_register (regcache, regno, buf);
-
-error_exit:;
 }
 
 /* Fetch all registers, or just one, from the child process.  */
@@ -2299,14 +2289,7 @@ usr_store_inferior_registers (struct reg
 		return;
 
 	      if ((*the_low_target.cannot_store_register) (regno) == 0)
-		{
-		  char *err = strerror (errno);
-		  char *msg = alloca (strlen (err) + 128);
-		  sprintf (msg, "writing register %d: %s",
-			   regno, err);
-		  error (msg);
-		  return;
-		}
+		error ("writing register %d: %s", regno, strerror (errno));
 	    }
 	  regaddr += sizeof (PTRACE_XFER_TYPE);
 	}


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