aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote-mips.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-04-19 15:28:42 +0000
committerPedro Alves <palves@redhat.com>2013-04-19 15:28:42 +0000
commitce6ec7d8d0bdec44a432131dfacc27917965f29f (patch)
treec2d33144418670d30f7a688386e326bdeb4c74e0 /gdb/remote-mips.c
parentfda0389f6a7b957340f66e16f2362eb4f9586069 (diff)
downloadgdb-ce6ec7d8d0bdec44a432131dfacc27917965f29f.zip
gdb-ce6ec7d8d0bdec44a432131dfacc27917965f29f.tar.gz
gdb-ce6ec7d8d0bdec44a432131dfacc27917965f29f.tar.bz2
-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.
Diffstat (limited to 'gdb/remote-mips.c')
-rw-r--r--gdb/remote-mips.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 85002ec..3b65b59 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -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;