[COMMIT PATCH] corefile.c: fix -Wpointer-sign

Pedro Alves palves@redhat.com
Thu Mar 7 23:36:00 GMT 2013


$ make WERROR_CFLAGS="-Wpointer-sign -Werror" corefile.o -k 2>&1 1>/dev/null
../../src/gdb/corefile.c: In function ‘read_memory_string’:
../../src/gdb/corefile.c:334:7: error: pointer targets in passing argument 2 of ‘read_memory’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/corefile.c:217:1: note: expected ‘gdb_byte *’ but argument is of type ‘char *’

Functions that take or return ascii-ish string arguments usually use
char* for parameters/return.  That means that at points we call into
target methods that work with binary blobs, we need casts to
gdb_byte*.

gdb/
2013-03-07  Pedro Alves  <palves@redhat.com>

	* corefile.c (read_memory_string): Cast pointer to gdb_byte* in
	call.
---
 gdb/corefile.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/corefile.c b/gdb/corefile.c
index b268d4c..9c795b8 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -331,7 +331,7 @@ read_memory_string (CORE_ADDR memaddr, char *buffer, int max_len)
       cnt = max_len - (cp - buffer);
       if (cnt > 8)
 	cnt = 8;
-      read_memory (memaddr + (int) (cp - buffer), cp, cnt);
+      read_memory (memaddr + (int) (cp - buffer), (gdb_byte *) cp, cnt);
       for (i = 0; i < cnt && *cp; i++, cp++)
 	;			/* null body */
 



More information about the Gdb-patches mailing list