target.c: fix -Wpointer-sign
authorPedro Alves <palves@redhat.com>
Thu, 7 Mar 2013 23:53:12 +0000 (23:53 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 7 Mar 2013 23:53:12 +0000 (23:53 +0000)
commit0c1f71e72813ee9096d7bcc7124cff430da79a18
treece1a40476498671ac3312ee5557f7bd3a5fdb203
parentc8af03a2f5d51f4c2de96ad9b6431553f0208f5c
target.c: fix -Wpointer-sign

$ make WERROR_CFLAGS="-Wpointer-sign -Werror" target.o -k 2>&1 1>/dev/null
../../src/gdb/target.c: In function ‘target_read_stralloc’:
../../src/gdb/target.c:2376:3: error: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Werror=pointer-sign]
In file included from build-gnulib/import/string.h:27:0,
                 from ../../src/gdb/common/gdb_string.h:24,
                 from ../../src/gdb/target.c:24:
/usr/include/string.h:399:15: note: expected ‘const char *’ but argument is of type ‘gdb_byte *’
...

This is about the same as the previous patch.

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/from
gdb_byte*/char*.  To choose which type for the variables, I usually go
based on which requires the fewer casts, and what the contents of the
variable are supposed to hold, which often gives the same answer.

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

* target.c (target_read_stralloc, target_fileio_read_alloc):
*Cast pointer to 'gdb_byte *' in target call.
gdb/ChangeLog
gdb/target.c