-Wpointer-sign: remote-mips.c.

remote-mips.c has a bunch of -Wpointer-sign warnings:

../../src/gdb/remote-mips.c: In function ‘mips_receive_packet’:
../../src/gdb/remote-mips.c:1128:7: error: pointer targets in passing argument 2 of ‘mips_cksum’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:830:1: note: expected ‘const unsigned char *’ but argument is of type ‘char *’
../../src/gdb/remote-mips.c:1135:7: error: pointer targets in passing argument 2 of ‘mips_cksum’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:830:1: note: expected ‘const unsigned char *’ but argument is of type ‘char *’
../../src/gdb/remote-mips.c: In function ‘mips_load_srec’:
../../src/gdb/remote-mips.c:2830:12: error: pointer targets in passing argument 4 of ‘mips_make_srec’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:134:12: note: expected ‘unsigned char *’ but argument is of type ‘char *’
../../src/gdb/remote-mips.c: In function ‘pmon_zeroset’:
../../src/gdb/remote-mips.c:3030:3: error: pointer targets in passing argument 4 of ‘pmon_makeb64’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:2977:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c: In function ‘pmon_make_fastrec’:
../../src/gdb/remote-mips.c:3124:6: error: pointer targets in passing argument 3 of ‘pmon_zeroset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3025:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3126:4: error: pointer targets in passing argument 4 of ‘pmon_makeb64’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:2977:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3148:3: error: pointer targets in passing argument 3 of ‘pmon_zeroset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3025:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3153:3: error: pointer targets in passing argument 3 of ‘pmon_zeroset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3025:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3154:8: error: pointer targets in passing argument 4 of ‘pmon_makeb64’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:2977:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c: In function ‘pmon_load_fast’:
../../src/gdb/remote-mips.c:3423:2: error: pointer targets in passing argument 4 of ‘pmon_makeb64’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:2977:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3457:4: error: pointer targets in passing argument 3 of ‘pmon_checkset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3051:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3484:8: error: pointer targets in passing argument 3 of ‘pmon_zeroset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3025:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3489:3: error: pointer targets in passing argument 3 of ‘pmon_checkset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3051:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’

The mips packet payload is ASCII, so it makes sense for
mips_send_packet and mips_receive_packet to expose 'char *'-based
interfaces, as currently they do.  But, mips packets have a binary
header, so if you look at e.g., mips_receive_packet's implementation,
you'll see "unsigned char" buffers in use.  I find it the most natural
to make the payload pointer passed to mips_cksum 'char *' too.

The other changes are straightforward adjustments -- a checksum is
naturally unsigned, and there's one point where we're reading a bfd section.

gdb/
2013-04-19  Pedro Alves  <palves@redhat.com>

	* remote-mips.c (mips_cksum): Rename 'data' parameter to 'datastr'
	and change its type to 'const char *'.  Adjust.
	(mips_send_packet): Add cast to 'char *', and remove cast to
	'unsigned char *'.
	(mips_receive_packet): Remove cast to 'unsigned char *'.
	(mips_load_srec): Use bfd_byte.
	(pmon_makeb64, pmon_zeroset): Make 'chksum' parameter unsigned.
	(pmon_checkset): Make 'value' parameter unsigned.
This commit is contained in:
Pedro Alves 2013-04-19 15:28:42 +00:00
parent fda0389f6a
commit ce6ec7d8d0
2 changed files with 28 additions and 15 deletions

View File

@ -1,3 +1,14 @@
2013-04-19 Pedro Alves <palves@redhat.com>
* remote-mips.c (mips_cksum): Rename 'data' parameter to 'datastr'
and change its type to 'const char *'. Adjust.
(mips_send_packet): Add cast to 'char *', and remove cast to
'unsigned char *'.
(mips_receive_packet): Remove cast to 'unsigned char *'.
(mips_load_srec): Use bfd_byte.
(pmon_makeb64, pmon_zeroset): Make 'chksum' parameter unsigned.
(pmon_checkset): Make 'value' parameter unsigned.
2013-04-19 Pedro Alves <palves@redhat.com>
* common/agent.c (agent_run_command): Add cast to gdb_byte *.

View File

@ -63,7 +63,7 @@ static int mips_receive_trailer (unsigned char *trlr, int *pgarbage,
int *pch, int timeout);
static int mips_cksum (const unsigned char *hdr,
const unsigned char *data, int len);
const char *data, int len);
static void mips_send_packet (const char *s, int get_ack);
@ -108,12 +108,12 @@ static void mips_files_info (struct target_ops *ignore);
static void mips_mourn_inferior (struct target_ops *ops);
static int pmon_makeb64 (unsigned long v, char *p, int n, int *chksum);
static int pmon_makeb64 (unsigned long v, char *p, int n, unsigned int *chksum);
static int pmon_zeroset (int recsize, char **buff, int *amount,
static int pmon_zeroset (int recsize, char **buff, unsigned int *amount,
unsigned int *chksum);
static int pmon_checkset (int recsize, char **buff, int *value);
static int pmon_checkset (int recsize, char **buff, unsigned int *value);
static void pmon_make_fastrec (char **outbuf, unsigned char *inbuf,
int *inptr, int inamount, int *recsize,
@ -824,12 +824,13 @@ mips_receive_trailer (unsigned char *trlr, int *pgarbage,
}
/* Get the checksum of a packet. HDR points to the packet header.
DATA points to the packet data. LEN is the length of DATA. */
DATASTR points to the packet data. LEN is the length of DATASTR. */
static int
mips_cksum (const unsigned char *hdr, const unsigned char *data, int len)
mips_cksum (const unsigned char *hdr, const char *datastr, int len)
{
const unsigned char *p;
const unsigned char *data = (const unsigned char *) datastr;
int c;
int cksum;
@ -872,7 +873,7 @@ mips_send_packet (const char *s, int get_ack)
memcpy (packet + HDR_LENGTH, s, len);
cksum = mips_cksum (packet, packet + HDR_LENGTH, len);
cksum = mips_cksum (packet, (char *) packet + HDR_LENGTH, len);
packet[HDR_LENGTH + len + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
packet[HDR_LENGTH + len + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
packet[HDR_LENGTH + len + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
@ -976,8 +977,7 @@ mips_send_packet (const char *s, int get_ack)
/* If the checksum does not match the trailer checksum, this
is a bad packet; ignore it. */
if (mips_cksum (hdr, (unsigned char *) NULL, 0)
!= TRLR_GET_CKSUM (trlr))
if (mips_cksum (hdr, NULL, 0) != TRLR_GET_CKSUM (trlr))
continue;
if (remote_debug > 0)
@ -1142,7 +1142,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
cksum = mips_cksum (ack, NULL, 0);
ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
@ -1183,7 +1183,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
cksum = mips_cksum (ack, NULL, 0);
ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
@ -2781,7 +2781,8 @@ mips_load_srec (char *args)
{
bfd *abfd;
asection *s;
char *buffer, srec[1024];
char srec[1024];
bfd_byte *buffer;
unsigned int i;
unsigned int srec_frame = 200;
int reclen;
@ -2974,7 +2975,7 @@ static char encoding[] =
characters written into the buffer. */
static int
pmon_makeb64 (unsigned long v, char *p, int n, int *chksum)
pmon_makeb64 (unsigned long v, char *p, int n, unsigned int *chksum)
{
int count = (n / 6);
@ -3022,7 +3023,8 @@ pmon_makeb64 (unsigned long v, char *p, int n, int *chksum)
escape sequence into the data stream. */
static int
pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum)
pmon_zeroset (int recsize, char **buff,
unsigned int *amount, unsigned int *chksum)
{
int count;
@ -3048,7 +3050,7 @@ pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum)
the record elements added by this call. */
static int
pmon_checkset (int recsize, char **buff, int *value)
pmon_checkset (int recsize, char **buff, unsigned int *value)
{
int count;