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
This commit is contained in:
Brian S. Dean 2005-08-30 01:30:05 +00:00
parent b7810ccb40
commit 5b6506ff17
9 changed files with 42 additions and 44 deletions

View File

@ -46,7 +46,7 @@ static char has_auto_incr_addr;
static int avr910_send(PROGRAMMER * pgm, char * buf, size_t len) 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; int rv;
rv = serial_recv(pgm->fd, buf, len); rv = serial_recv(pgm->fd, (unsigned char *)buf, len);
if (rv < 0) { if (rv < 0) {
fprintf(stderr, fprintf(stderr,
"%s: avr910_recv(): programmer is not responding\n", "%s: avr910_recv(): programmer is not responding\n",
@ -134,7 +134,7 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
char hw[2]; char hw[2];
char buf[10]; char buf[10];
char type; char type;
unsigned char c; char c;
int dev_supported = 0; int dev_supported = 0;
AVRPART * part; AVRPART * part;
@ -232,7 +232,7 @@ static void avr910_enable(PROGRAMMER * pgm)
static int avr910_cmd(PROGRAMMER * pgm, unsigned char cmd[4], static int avr910_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4]) unsigned char res[4])
{ {
unsigned char buf[5]; char buf[5];
/* FIXME: Insert version check here */ /* 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) static void avr910_set_addr(PROGRAMMER * pgm, unsigned long addr)
{ {
unsigned char cmd[3]; char cmd[3];
cmd[0] = 'A'; cmd[0] = 'A';
cmd[1] = (addr >> 8) & 0xff; 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, static int avr910_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned long addr, unsigned char value) unsigned long addr, unsigned char value)
{ {
unsigned char cmd[2]; char cmd[2];
if (strcmp(m->desc, "flash") == 0) { if (strcmp(m->desc, "flash") == 0) {
if (addr & 0x01) { if (addr & 0x01) {
@ -347,7 +347,7 @@ static int avr910_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cached = 0; cached = 0;
} }
else { else {
unsigned char buf[2]; char buf[2];
avr910_set_addr(pgm, addr >> 1); 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_set_addr(pgm, addr);
avr910_send(pgm, "d", 1); avr910_send(pgm, "d", 1);
avr910_recv(pgm, value, 1); avr910_recv(pgm, (char *)value, 1);
return 0; return 0;
} }
@ -401,7 +401,7 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes) int page_size, int n_bytes)
{ {
unsigned char cmd[] = {'c', 'C'}; unsigned char cmd[] = {'c', 'C'};
unsigned char buf[2]; char buf[2];
unsigned int addr = 0; unsigned int addr = 0;
unsigned int max_addr = n_bytes; unsigned int max_addr = n_bytes;
unsigned int page_addr; 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, static int avr910_paged_write_eeprom(PROGRAMMER * pgm, AVRPART * p,
AVRMEM * m, int page_size, int n_bytes) AVRMEM * m, int page_size, int n_bytes)
{ {
unsigned char cmd[2]; char cmd[2];
unsigned int addr = 0; unsigned int addr = 0;
unsigned int max_addr = n_bytes; 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, static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes) int page_size, int n_bytes)
{ {
unsigned char cmd; char cmd;
int rd_size; int rd_size;
unsigned int addr = 0; unsigned int addr = 0;
unsigned int max_addr; unsigned int max_addr;
unsigned char buf[2]; char buf[2];
if (strcmp(m->desc, "flash") == 0) { if (strcmp(m->desc, "flash") == 0) {
cmd = 'R'; 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 */ m->buf[addr*2+1] = buf[0]; /* MSB */
} }
else { else {
avr910_recv(pgm, &m->buf[addr], 1); avr910_recv(pgm, (char *)&m->buf[addr], 1);
} }
addr++; addr++;
@ -557,7 +557,7 @@ static int avr910_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
} }
avr910_send(pgm, "s", 1); avr910_send(pgm, "s", 1);
avr910_recv(pgm, m->buf, 3); avr910_recv(pgm, (char *)m->buf, 3);
return 3; return 3;
} }

View File

@ -69,7 +69,7 @@ static int butterfly_send(PROGRAMMER * pgm, char * buf, size_t len)
{ {
no_show_func_info(); 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(); no_show_func_info();
rv = serial_recv(pgm->fd, buf, len); rv = serial_recv(pgm->fd, (unsigned char *)buf, len);
if (rv < 0) { if (rv < 0) {
fprintf(stderr, fprintf(stderr,
"%s: butterfly_recv(): programmer is not responding\n", "%s: butterfly_recv(): programmer is not responding\n",
@ -226,7 +226,7 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
char hw[2]; char hw[2];
char buf[10]; char buf[10];
char type; char type;
unsigned char c; char c;
int dev_supported = 0; int dev_supported = 0;
no_show_func_info(); 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) static void butterfly_set_addr(PROGRAMMER * pgm, unsigned long addr)
{ {
unsigned char cmd[3]; char cmd[3];
cmd[0] = 'A'; cmd[0] = 'A';
cmd[1] = (addr >> 8) & 0xff; 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, static int butterfly_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned long addr, unsigned char value) unsigned long addr, unsigned char value)
{ {
unsigned char cmd[6]; char cmd[6];
int size; int size;
no_show_func_info(); no_show_func_info();
@ -460,7 +460,7 @@ static int butterfly_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cached = 0; cached = 0;
} }
else { else {
unsigned char buf[2]; char buf[2];
butterfly_set_addr(pgm, addr >> 1); 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_set_addr(pgm, addr);
butterfly_send(pgm, "g\000\001E", 4); butterfly_send(pgm, "g\000\001E", 4);
butterfly_recv(pgm, value, 1); butterfly_recv(pgm, (char *)value, 1);
return 0; 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, static int butterfly_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned long addr, unsigned char * value) unsigned long addr, unsigned char * value)
{ {
unsigned char cmd; char cmd;
no_show_func_info(); no_show_func_info();
@ -525,7 +525,7 @@ static int butterfly_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -1; return -1;
butterfly_send(pgm, &cmd, 1); butterfly_send(pgm, &cmd, 1);
butterfly_recv(pgm, value, 1); butterfly_recv(pgm, (char *)value, 1);
return *value == '?'? -1: 0; 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 addr = 0;
unsigned int max_addr = n_bytes; unsigned int max_addr = n_bytes;
unsigned char *cmd; char *cmd;
unsigned int blocksize = buffersize; unsigned int blocksize = buffersize;
if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom")) 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; return -2;
{ /* use buffered mode */ { /* use buffered mode */
unsigned char cmd[4]; char cmd[4];
int blocksize = buffersize; int blocksize = buffersize;
cmd[0] = 'g'; cmd[0] = 'g';
@ -608,7 +608,7 @@ static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd[2] = blocksize & 0xff; cmd[2] = blocksize & 0xff;
butterfly_send(pgm, cmd, 4); butterfly_send(pgm, cmd, 4);
butterfly_recv(pgm, &m->buf[addr], blocksize); butterfly_recv(pgm, (char *)&m->buf[addr], blocksize);
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_send(pgm, "s", 1);
butterfly_recv(pgm, m->buf, 3); butterfly_recv(pgm, (char *)m->buf, 3);
/* Returned signature has wrong order. */ /* Returned signature has wrong order. */
tmp = m->buf[2]; tmp = m->buf[2];
m->buf[2] = m->buf[0]; m->buf[2] = m->buf[0];

View File

@ -295,7 +295,7 @@ static int jtagmkII_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
unsigned char *buf; unsigned char *buf;
if (verbose >= 3) 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); progname, len);
if ((buf = malloc(len + 10)) == NULL) if ((buf = malloc(len + 10)) == NULL)
@ -627,7 +627,7 @@ static int jtagmkII_getsync(PROGRAMMER * pgm) {
#undef FWVER #undef FWVER
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, 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); progname, device_descriptor_length);
/* Turn the ICE into JTAG mode */ /* Turn the ICE into JTAG mode */
@ -1698,7 +1698,7 @@ static int jtagmkII_setparm(PROGRAMMER * pgm, unsigned char parm,
memcpy(buf + 2, value, size); memcpy(buf + 2, value, size);
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_setparm(): " 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); progname, parm, size);
jtagmkII_send(pgm, buf, size + 2); jtagmkII_send(pgm, buf, size + 2);

View File

@ -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! */ /* 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; unsigned char value;

View File

@ -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); 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! */ /* 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 /* 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 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

View File

@ -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; struct timeval timeout, to2;
fd_set wfds; fd_set wfds;
int nfds; int nfds;
int rc; int rc;
unsigned char * p = buf;
char * p = buf;
size_t len = buflen; size_t len = buflen;
if (!len) 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; struct timeval timeout, to2;
fd_set rfds; fd_set rfds;
int nfds; int nfds;
int rc; int rc;
unsigned char * p = buf;
char * p = buf;
size_t len = 0; size_t len = 0;
timeout.tv_sec = serial_recv_timeout / 1000L; timeout.tv_sec = serial_recv_timeout / 1000L;

View File

@ -38,8 +38,8 @@ struct serial_device
int (*setspeed)(int fd, long baud); int (*setspeed)(int fd, long baud);
void (*close)(int fd); void (*close)(int fd);
int (*send)(int fd, char * buf, size_t buflen); int (*send)(int fd, unsigned char * buf, size_t buflen);
int (*recv)(int fd, char * buf, size_t buflen); int (*recv)(int fd, unsigned char * buf, size_t buflen);
int (*drain)(int fd, int display); int (*drain)(int fd, int display);
}; };

View File

@ -55,13 +55,13 @@ static int stk500_is_page_empty(unsigned int address, int page_size,
const unsigned char *buf); 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); 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; int rv;

View File

@ -173,7 +173,7 @@ static int stk500v2_recv(PROGRAMMER * pgm, unsigned char msg[], size_t maxsize)
if (curlen < maxsize) { if (curlen < maxsize) {
msg[curlen] = c; msg[curlen] = c;
} else { } 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); progname,curlen,maxsize);
return -2; return -2;
} }
@ -271,7 +271,7 @@ retry:
return 0; 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 i;
int tries = 0; int tries = 0;
int status; int status;