From 8420b272335a0db7c86162ffe77f0692dfb18235 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Aug 2022 14:58:21 +0100 Subject: [PATCH] Address compiler warnings in 4 source files --- src/developer_opts.c | 9 +++------ src/jtagmkII.c | 2 -- src/ser_win32.c | 6 +++--- src/stk500v2.c | 10 +++++++--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index e0c274b9..dc7a4063 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -402,14 +402,11 @@ static int avrpart_deep_copy(AVRPARTdeep *d, const AVRPART *p) { // Copy over desc, id, and family_id memset(d->descbuf, 0, sizeof d->descbuf); - if(d->descbuf) - strncpy(d->descbuf, p->desc, sizeof d->descbuf-1); + strncpy(d->descbuf, p->desc, sizeof d->descbuf-1); memset(d->idbuf, 0, sizeof d->idbuf); - if(d->idbuf) - strncpy(d->idbuf, p->id, sizeof d->idbuf-1); + strncpy(d->idbuf, p->id, sizeof d->idbuf-1); memset(d->family_idbuf, 0, sizeof d->family_idbuf); - if(d->family_idbuf) - strncpy(d->family_idbuf, p->family_id, sizeof d->family_idbuf-1); + strncpy(d->family_idbuf, p->family_id, sizeof d->family_idbuf-1); // Zap address values d->base.desc = NULL; diff --git a/src/jtagmkII.c b/src/jtagmkII.c index f52f3bc3..ef45ee22 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -488,7 +488,6 @@ static int jtagmkII_recv_frame(PROGRAMMER * pgm, unsigned char **msg, int rv; unsigned char c, *buf = NULL, header[8]; unsigned short r_seqno = 0; - unsigned short checksum = 0; struct timeval tv; double timeoutval = 100; /* seconds */ @@ -521,7 +520,6 @@ static int jtagmkII_recv_frame(PROGRAMMER * pgm, unsigned char **msg, if (serial_recv(&pgm->fd, &c, 1) != 0) goto timedout; } - checksum ^= c; if (state < sDATA) header[headeridx++] = c; diff --git a/src/ser_win32.c b/src/ser_win32.c index fa4d7aba..970a3ecb 100644 --- a/src/ser_win32.c +++ b/src/ser_win32.c @@ -393,7 +393,7 @@ static int net_send(union filedescriptor *fd, const unsigned char * buf, size_t } while (len) { - rc = send(fd->ifd, p, (len > 1024) ? 1024 : len, 0); + rc = send(fd->ifd, (const char *) p, (len > 1024)? 1024: len, 0); if (rc < 0) { FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | @@ -527,7 +527,7 @@ reselect: } } - rc = recv(fd->ifd, p, (buflen - len > 1024) ? 1024 : buflen - len, 0); + rc = recv(fd->ifd, (char *) p, (buflen - len > 1024)? 1024: buflen - len, 0); if (rc < 0) { FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | @@ -693,7 +693,7 @@ static int net_drain(union filedescriptor *fd, int display) } } - rc = recv(fd->ifd, &buf, 1, 0); + rc = recv(fd->ifd, (char *) &buf, 1, 0); if (rc < 0) { FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | diff --git a/src/stk500v2.c b/src/stk500v2.c index a50fda4c..8f16ae41 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -3093,12 +3093,14 @@ static int stk500v2_setparm_real(PROGRAMMER * pgm, unsigned char parm, unsigned static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value) { - unsigned char current_value; + unsigned char current_value = value; int res; res = stk500v2_getparm(pgm, parm, ¤t_value); - if (res < 0) + if (res < 0) { avrdude_message(MSG_INFO, "%s: Unable to get parameter 0x%02x\n", progname, parm); + return -1; + } // don't issue a write if the correct value is already set. if (value == current_value) { @@ -3245,7 +3247,7 @@ f_to_kHz_MHz(double f, const char **unit) static void stk500v2_print_parms1(PROGRAMMER * pgm, const char * p) { - unsigned char vtarget, vadjust, osc_pscale, osc_cmatch, sck_duration =0; //XXX 0 is not correct, check caller + unsigned char vtarget = 0, vadjust = 0, osc_pscale = 0, osc_cmatch = 0, sck_duration =0; //XXX 0 is not correct, check caller unsigned int sck_stk600, clock_conf, dac, oct, varef; unsigned char vtarget_jtag[4]; int prescale; @@ -3253,6 +3255,8 @@ static void stk500v2_print_parms1(PROGRAMMER * pgm, const char * p) const char *unit; void *mycookie; + memset(vtarget_jtag, 0, sizeof vtarget_jtag); + if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII) { mycookie = pgm->cookie; pgm->cookie = PDATA(pgm)->chained_pdata;