Skip to content

Commit

Permalink
Merge pull request #5821 from makomi/tunslip
Browse files Browse the repository at this point in the history
dist/tools/tunslip: fix cppcheck warnings
  • Loading branch information
Joakim Nohlgård authored Oct 14, 2016
2 parents d79cd42 + 5456d6e commit bee918b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
9 changes: 4 additions & 5 deletions dist/tools/tunslip/tapslip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void
write_to_serial(int outfd, void *inbuf, int len)
{
u_int8_t *p = inbuf;
int i, ecode;
int i;

/* printf("Got packet of length %d - write SLIP\n", len);*/
/* print_packet(p, len);*/
Expand Down Expand Up @@ -543,8 +543,7 @@ int
main(int argc, char **argv)
{
int c;
int tunfd, slipfd, maxfd;
int ret;
int tunfd, slipfd;
fd_set rset, wset;
FILE *inslip;
const char *siodev = NULL;
Expand Down Expand Up @@ -681,7 +680,7 @@ main(int argc, char **argv)
ifconf(tundev, ipaddr, netmask);

while (1) {
maxfd = 0;
int maxfd = 0;
FD_ZERO(&rset);
FD_ZERO(&wset);

Expand Down Expand Up @@ -723,7 +722,7 @@ main(int argc, char **argv)
}
}

ret = select(maxfd + 1, &rset, &wset, NULL, NULL);
int ret = select(maxfd + 1, &rset, &wset, NULL, NULL);

if (ret == -1 && errno != EINTR) {
err(1, "select");
Expand Down
9 changes: 4 additions & 5 deletions dist/tools/tunslip/tunslip.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ relay_dhcp_to_client(int slipfd)

case DHCP_OPTION_MSG_TYPE:
msg_type = p[2];

/* deliberate fall-through */
case DHCP_OPTION_SUBNET_MASK:
case DHCP_OPTION_ROUTER:
case DHCP_OPTION_LEASE_TIME:
Expand Down Expand Up @@ -969,8 +969,7 @@ int
main(int argc, char **argv)
{
int c;
int tunfd, slipfd, maxfd;
int ret;
int tunfd, slipfd;
fd_set rset, wset;
FILE *inslip;
const char *siodev = NULL;
Expand Down Expand Up @@ -1196,7 +1195,7 @@ main(int argc, char **argv)
ifconf(tundev, ipaddr, netmask);

while (1) {
maxfd = 0;
int maxfd = 0;
FD_ZERO(&rset);
FD_ZERO(&wset);

Expand Down Expand Up @@ -1237,7 +1236,7 @@ main(int argc, char **argv)
}
}

ret = select(maxfd + 1, &rset, &wset, NULL, NULL);
int ret = select(maxfd + 1, &rset, &wset, NULL, NULL);

if (ret == -1 && errno != EINTR) {
err(1, "select");
Expand Down
16 changes: 6 additions & 10 deletions dist/tools/tunslip/tunslip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ stamptime(void)
long secs, msecs;
struct timeval tv;
time_t t;
struct tm *tmp;
char timec[20];

gettimeofday(&tv, NULL) ;
Expand All @@ -131,13 +130,13 @@ stamptime(void)
msecs += 1000;
}

fprintf(stderr, "%04lu.%03lu ", secs, msecs);
fprintf(stderr, "%04li.%03li ", secs, msecs);
}
else {
startsecs = secs;
startmsecs = msecs;
t = time(NULL);
tmp = localtime(&t);
struct tm *tmp = localtime(&t);
strftime(timec, sizeof(timec), "%T", tmp);
// fprintf(stderr,"\n%s.%03lu ",timec,msecs);
fprintf(stderr, "\n%s ", timec);
Expand Down Expand Up @@ -899,8 +898,7 @@ int
main(int argc, char **argv)
{
int c;
int tunfd, maxfd;
int ret;
int tunfd;
fd_set rset, wset;
FILE *inslip;
const char *siodev = NULL;
Expand Down Expand Up @@ -1187,7 +1185,7 @@ main(int argc, char **argv)
ifconf(tundev, ipaddr);

while (1) {
maxfd = 0;
int maxfd = 0;
FD_ZERO(&rset);
FD_ZERO(&wset);

Expand Down Expand Up @@ -1221,7 +1219,7 @@ main(int argc, char **argv)
}
}

ret = select(maxfd + 1, &rset, &wset, NULL, NULL);
int ret = select(maxfd + 1, &rset, &wset, NULL, NULL);

if (ret == -1 && errno != EINTR) {
err(1, "select");
Expand Down Expand Up @@ -1254,10 +1252,8 @@ main(int argc, char **argv)
}

if (delaymsec == 0) {
int size;

if (slip_empty() && FD_ISSET(tunfd, &rset)) {
size = tun_to_serial(tunfd, slipfd);
int size = tun_to_serial(tunfd, slipfd);
slip_flushbuf(slipfd);
sigalarm_reset();

Expand Down

0 comments on commit bee918b

Please sign in to comment.