From 5b6506ff17ae8cc165c1d513e8916f3787a6ff9f Mon Sep 17 00:00:00 2001 From: "Brian S. Dean" Date: Tue, 30 Aug 2005 01:30:05 +0000 Subject: [PATCH] Eliminate compiler warnings. GCC 4.x elicits many signedness warnings when passing unsigned char * when char * is in the prototype and vice versa. Clean these up along with a few others. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@491 81a1dc3b-b13d-400b-aceb-764788c761c2 --- avrdude/avr910.c | 28 ++++++++++++++-------------- avrdude/butterfly.c | 26 +++++++++++++------------- avrdude/jtagmkII.c | 6 +++--- avrdude/safemode.c | 2 +- avrdude/safemode.h | 2 +- avrdude/ser_posix.c | 10 ++++------ avrdude/serial.h | 4 ++-- avrdude/stk500.c | 4 ++-- avrdude/stk500v2.c | 4 ++-- 9 files changed, 42 insertions(+), 44 deletions(-) diff --git a/avrdude/avr910.c b/avrdude/avr910.c index 63bd6855..e0a97fac 100644 --- a/avrdude/avr910.c +++ b/avrdude/avr910.c @@ -46,7 +46,7 @@ static char has_auto_incr_addr; static int avr910_send(PROGRAMMER * pgm, char * buf, size_t len) { - return serial_send(pgm->fd, buf, len); + return serial_send(pgm->fd, (unsigned char *)buf, len); } @@ -54,7 +54,7 @@ static int avr910_recv(PROGRAMMER * pgm, char * buf, size_t len) { int rv; - rv = serial_recv(pgm->fd, buf, len); + rv = serial_recv(pgm->fd, (unsigned char *)buf, len); if (rv < 0) { fprintf(stderr, "%s: avr910_recv(): programmer is not responding\n", @@ -134,7 +134,7 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p) char hw[2]; char buf[10]; char type; - unsigned char c; + char c; int dev_supported = 0; AVRPART * part; @@ -232,7 +232,7 @@ static void avr910_enable(PROGRAMMER * pgm) static int avr910_cmd(PROGRAMMER * pgm, unsigned char cmd[4], unsigned char res[4]) { - unsigned char buf[5]; + char buf[5]; /* FIXME: Insert version check here */ @@ -291,7 +291,7 @@ static void avr910_display(PROGRAMMER * pgm, char * p) static void avr910_set_addr(PROGRAMMER * pgm, unsigned long addr) { - unsigned char cmd[3]; + char cmd[3]; cmd[0] = 'A'; cmd[1] = (addr >> 8) & 0xff; @@ -305,7 +305,7 @@ static void avr910_set_addr(PROGRAMMER * pgm, unsigned long addr) static int avr910_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr, unsigned char value) { - unsigned char cmd[2]; + char cmd[2]; if (strcmp(m->desc, "flash") == 0) { if (addr & 0x01) { @@ -347,7 +347,7 @@ static int avr910_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, cached = 0; } else { - unsigned char buf[2]; + char buf[2]; avr910_set_addr(pgm, addr >> 1); @@ -376,7 +376,7 @@ static int avr910_read_byte_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, { avr910_set_addr(pgm, addr); avr910_send(pgm, "d", 1); - avr910_recv(pgm, value, 1); + avr910_recv(pgm, (char *)value, 1); return 0; } @@ -401,7 +401,7 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int page_size, int n_bytes) { unsigned char cmd[] = {'c', 'C'}; - unsigned char buf[2]; + char buf[2]; unsigned int addr = 0; unsigned int max_addr = n_bytes; unsigned int page_addr; @@ -456,7 +456,7 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, static int avr910_paged_write_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int page_size, int n_bytes) { - unsigned char cmd[2]; + char cmd[2]; unsigned int addr = 0; unsigned int max_addr = n_bytes; @@ -500,11 +500,11 @@ static int avr910_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int page_size, int n_bytes) { - unsigned char cmd; + char cmd; int rd_size; unsigned int addr = 0; unsigned int max_addr; - unsigned char buf[2]; + char buf[2]; if (strcmp(m->desc, "flash") == 0) { cmd = 'R'; @@ -532,7 +532,7 @@ static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, m->buf[addr*2+1] = buf[0]; /* MSB */ } else { - avr910_recv(pgm, &m->buf[addr], 1); + avr910_recv(pgm, (char *)&m->buf[addr], 1); } addr++; @@ -557,7 +557,7 @@ static int avr910_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m) } avr910_send(pgm, "s", 1); - avr910_recv(pgm, m->buf, 3); + avr910_recv(pgm, (char *)m->buf, 3); return 3; } diff --git a/avrdude/butterfly.c b/avrdude/butterfly.c index 97f99c14..358f660c 100644 --- a/avrdude/butterfly.c +++ b/avrdude/butterfly.c @@ -69,7 +69,7 @@ static int butterfly_send(PROGRAMMER * pgm, char * buf, size_t len) { no_show_func_info(); - return serial_send(pgm->fd, buf, len); + return serial_send(pgm->fd, (unsigned char *)buf, len); } @@ -79,7 +79,7 @@ static int butterfly_recv(PROGRAMMER * pgm, char * buf, size_t len) no_show_func_info(); - rv = serial_recv(pgm->fd, buf, len); + rv = serial_recv(pgm->fd, (unsigned char *)buf, len); if (rv < 0) { fprintf(stderr, "%s: butterfly_recv(): programmer is not responding\n", @@ -226,7 +226,7 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p) char hw[2]; char buf[10]; char type; - unsigned char c; + char c; int dev_supported = 0; no_show_func_info(); @@ -396,7 +396,7 @@ static void butterfly_display(PROGRAMMER * pgm, char * p) static void butterfly_set_addr(PROGRAMMER * pgm, unsigned long addr) { - unsigned char cmd[3]; + char cmd[3]; cmd[0] = 'A'; cmd[1] = (addr >> 8) & 0xff; @@ -411,7 +411,7 @@ static void butterfly_set_addr(PROGRAMMER * pgm, unsigned long addr) static int butterfly_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr, unsigned char value) { - unsigned char cmd[6]; + char cmd[6]; int size; no_show_func_info(); @@ -460,7 +460,7 @@ static int butterfly_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, cached = 0; } else { - unsigned char buf[2]; + char buf[2]; butterfly_set_addr(pgm, addr >> 1); @@ -489,7 +489,7 @@ static int butterfly_read_byte_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, { butterfly_set_addr(pgm, addr); butterfly_send(pgm, "g\000\001E", 4); - butterfly_recv(pgm, value, 1); + butterfly_recv(pgm, (char *)value, 1); return 0; } @@ -497,7 +497,7 @@ static int butterfly_read_byte_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, static int butterfly_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr, unsigned char * value) { - unsigned char cmd; + char cmd; no_show_func_info(); @@ -525,7 +525,7 @@ static int butterfly_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, return -1; butterfly_send(pgm, &cmd, 1); - butterfly_recv(pgm, value, 1); + butterfly_recv(pgm, (char *)value, 1); return *value == '?'? -1: 0; } @@ -537,7 +537,7 @@ static int butterfly_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, { unsigned int addr = 0; unsigned int max_addr = n_bytes; - unsigned char *cmd; + char *cmd; unsigned int blocksize = buffersize; if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom")) @@ -593,7 +593,7 @@ static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, return -2; { /* use buffered mode */ - unsigned char cmd[4]; + char cmd[4]; int blocksize = buffersize; cmd[0] = 'g'; @@ -608,7 +608,7 @@ static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, cmd[2] = blocksize & 0xff; butterfly_send(pgm, cmd, 4); - butterfly_recv(pgm, &m->buf[addr], blocksize); + butterfly_recv(pgm, (char *)&m->buf[addr], blocksize); addr += blocksize; @@ -633,7 +633,7 @@ static int butterfly_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m) } butterfly_send(pgm, "s", 1); - butterfly_recv(pgm, m->buf, 3); + butterfly_recv(pgm, (char *)m->buf, 3); /* Returned signature has wrong order. */ tmp = m->buf[2]; m->buf[2] = m->buf[0]; diff --git a/avrdude/jtagmkII.c b/avrdude/jtagmkII.c index ea7fe2a7..976f5439 100644 --- a/avrdude/jtagmkII.c +++ b/avrdude/jtagmkII.c @@ -295,7 +295,7 @@ static int jtagmkII_send(PROGRAMMER * pgm, unsigned char * data, size_t len) unsigned char *buf; if (verbose >= 3) - fprintf(stderr, "\n%s: jtagmkII_send(): sending %d bytes\n", + fprintf(stderr, "\n%s: jtagmkII_send(): sending %zd bytes\n", progname, len); if ((buf = malloc(len + 10)) == NULL) @@ -627,7 +627,7 @@ static int jtagmkII_getsync(PROGRAMMER * pgm) { #undef FWVER if (verbose >= 2) fprintf(stderr, - "%s: jtagmkII_getsync(): Using a %u-byte device descriptor\n", + "%s: jtagmkII_getsync(): Using a %zu-byte device descriptor\n", progname, device_descriptor_length); /* Turn the ICE into JTAG mode */ @@ -1698,7 +1698,7 @@ static int jtagmkII_setparm(PROGRAMMER * pgm, unsigned char parm, memcpy(buf + 2, value, size); if (verbose >= 2) fprintf(stderr, "%s: jtagmkII_setparm(): " - "Sending set parameter command (parm 0x%02x, %u bytes): ", + "Sending set parameter command (parm 0x%02x, %zu bytes): ", progname, parm, size); jtagmkII_send(pgm, buf, size + 2); diff --git a/avrdude/safemode.c b/avrdude/safemode.c index 60f51fc7..5a20178b 100644 --- a/avrdude/safemode.c +++ b/avrdude/safemode.c @@ -66,7 +66,7 @@ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm, A } /* Reads the fuses three times, checking that all readings are the same. This will ensure that the before values aren't in error! */ -int safemode_readfuses (char * lfuse, char * hfuse, char * efuse, PROGRAMMER * pgm, AVRPART * p, int verbose) +int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, PROGRAMMER * pgm, AVRPART * p, int verbose) { unsigned char value; diff --git a/avrdude/safemode.h b/avrdude/safemode.h index d854e237..7e5c4d83 100644 --- a/avrdude/safemode.h +++ b/avrdude/safemode.h @@ -28,7 +28,7 @@ amount of times before giving up */ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm, AVRPART * p, int tries, int verbose); /* Reads the fuses three times, checking that all readings are the same. This will ensure that the before values aren't in error! */ -int safemode_readfuses (char * lfuse, char * hfuse, char * efuse, PROGRAMMER * pgm, AVRPART * p, int verbose); +int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, PROGRAMMER * pgm, AVRPART * p, int verbose); /* This routine will store the current values pointed to by lfuse, hfuse, and efuse into an internal buffer in this routine when save is set to 1. When save is 0 (or not 1 really) it will copy the values from the internal buffer into the locations diff --git a/avrdude/ser_posix.c b/avrdude/ser_posix.c index 47f2ab5c..990476ff 100644 --- a/avrdude/ser_posix.c +++ b/avrdude/ser_posix.c @@ -167,14 +167,13 @@ static void ser_close(int fd) } -static int ser_send(int fd, char * buf, size_t buflen) +static int ser_send(int fd, unsigned char * buf, size_t buflen) { struct timeval timeout, to2; fd_set wfds; int nfds; int rc; - - char * p = buf; + unsigned char * p = buf; size_t len = buflen; if (!len) @@ -243,14 +242,13 @@ static int ser_send(int fd, char * buf, size_t buflen) } -static int ser_recv(int fd, char * buf, size_t buflen) +static int ser_recv(int fd, unsigned char * buf, size_t buflen) { struct timeval timeout, to2; fd_set rfds; int nfds; int rc; - - char * p = buf; + unsigned char * p = buf; size_t len = 0; timeout.tv_sec = serial_recv_timeout / 1000L; diff --git a/avrdude/serial.h b/avrdude/serial.h index 5dc8d745..5b557032 100644 --- a/avrdude/serial.h +++ b/avrdude/serial.h @@ -38,8 +38,8 @@ struct serial_device int (*setspeed)(int fd, long baud); void (*close)(int fd); - int (*send)(int fd, char * buf, size_t buflen); - int (*recv)(int fd, char * buf, size_t buflen); + int (*send)(int fd, unsigned char * buf, size_t buflen); + int (*recv)(int fd, unsigned char * buf, size_t buflen); int (*drain)(int fd, int display); }; diff --git a/avrdude/stk500.c b/avrdude/stk500.c index 6e3532ad..b131a720 100644 --- a/avrdude/stk500.c +++ b/avrdude/stk500.c @@ -55,13 +55,13 @@ static int stk500_is_page_empty(unsigned int address, int page_size, const unsigned char *buf); -static int stk500_send(PROGRAMMER * pgm, char * buf, size_t len) +static int stk500_send(PROGRAMMER * pgm, unsigned char * buf, size_t len) { return serial_send(pgm->fd, buf, len); } -static int stk500_recv(PROGRAMMER * pgm, char * buf, size_t len) +static int stk500_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len) { int rv; diff --git a/avrdude/stk500v2.c b/avrdude/stk500v2.c index eaf54095..b7d1cd2c 100644 --- a/avrdude/stk500v2.c +++ b/avrdude/stk500v2.c @@ -173,7 +173,7 @@ static int stk500v2_recv(PROGRAMMER * pgm, unsigned char msg[], size_t maxsize) if (curlen < maxsize) { msg[curlen] = c; } else { - fprintf(stderr, "%s: stk500v2_recv(): buffer too small, received %d byte into %d byte buffer\n", + fprintf(stderr, "%s: stk500v2_recv(): buffer too small, received %d byte into %zd byte buffer\n", progname,curlen,maxsize); return -2; } @@ -271,7 +271,7 @@ retry: return 0; } -static int stk500v2_command(PROGRAMMER * pgm, char * buf, size_t len, size_t maxlen) { +static int stk500v2_command(PROGRAMMER * pgm, unsigned char * buf, size_t len, size_t maxlen) { int i; int tries = 0; int status;