From 2cb16c5ff41645c7dc6c0dc21d4589215308ef0d Mon Sep 17 00:00:00 2001 From: Oleg Hahm <oleg@hobbykeller.org> Date: Tue, 28 Mar 2017 20:12:06 +0200 Subject: [PATCH] dist: tunslip: fix cppcheck warnings --- dist/tools/tunslip/tapslip6.c | 1 - dist/tools/tunslip/tunslip.c | 3 +-- dist/tools/tunslip/tunslip6.c | 14 +++++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/dist/tools/tunslip/tapslip6.c b/dist/tools/tunslip/tapslip6.c index 497ad710bd..0ae6605e27 100644 --- a/dist/tools/tunslip/tapslip6.c +++ b/dist/tools/tunslip/tapslip6.c @@ -172,7 +172,6 @@ after_fread: if (ret == 0) { clearerr(inslip); - return; fprintf(stderr, "serial_to_tun: EOF\n"); exit(1); } diff --git a/dist/tools/tunslip/tunslip.c b/dist/tools/tunslip/tunslip.c index 9b8f4a4bfb..117bedc97d 100644 --- a/dist/tools/tunslip/tunslip.c +++ b/dist/tools/tunslip/tunslip.c @@ -307,7 +307,7 @@ done: if (op == DHCP_OPTION_END) { *t++ = op; - *p++; + (*p)++; } optlen = t - pkt.m.options; @@ -535,7 +535,6 @@ after_fread: if (ret == 0) { clearerr(inslip); - return; fprintf(stderr, "serial_to_tun: EOF\n"); exit(1); } diff --git a/dist/tools/tunslip/tunslip6.c b/dist/tools/tunslip/tunslip6.c index 286a459fd4..67ad3a0d5c 100644 --- a/dist/tools/tunslip/tunslip6.c +++ b/dist/tools/tunslip/tunslip6.c @@ -118,7 +118,6 @@ stamptime(void) long secs, msecs; struct timeval tv; time_t t; - char timec[20]; gettimeofday(&tv, NULL) ; msecs = tv.tv_usec / 1000; @@ -136,6 +135,7 @@ stamptime(void) fprintf(stderr, "%04li.%03li ", secs, msecs); } else { + char timec[20]; startsecs = secs; startmsecs = msecs; t = time(NULL); @@ -190,6 +190,8 @@ serial_to_tun(FILE *inslip, int outfd) unsigned char inbuf[2000]; } uip; static unsigned int inbufptr = 0; + /* cppcheck-suppress variableScope + * rationale: cannot be reduced if built on linux */ int ret; unsigned char c; @@ -209,7 +211,7 @@ serial_to_tun(FILE *inslip, int outfd) stamptime(); } - fprintf(stderr, "*** dropping large %d byte packet\n", inbufptr); + fprintf(stderr, "*** dropping large %u byte packet\n", inbufptr); inbufptr = 0; } @@ -324,7 +326,7 @@ serial_to_tun(FILE *inslip, int outfd) stamptime(); } - printf("Packet from SLIP of length %d - write TUN\n", inbufptr); + printf("Packet from SLIP of length %u - write TUN\n", inbufptr); if (verbose > 4) { #if WIRESHARK_IMPORT_FORMAT @@ -648,6 +650,8 @@ devopen(const char *dev, int flags) { char t[1024]; strcpy(t, "/dev/"); + /* cppcheck-suppress bufferAccessOutOfBounds + * reason: seems to be a cppcheck bug */ strncat(t, dev, sizeof(t) - 5); return open(t, flags); } @@ -868,10 +872,6 @@ ifconf(const char *tundev, const char *ipaddr) if (prefix != NULL) { *prefix = '\0'; - prefix++; - } - else { - prefix = "64"; } if (timestamp) { -- GitLab