Skip to content

Commit

Permalink
Fix the coverity TAINTED_SCALAR warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Liming Sun <[email protected]>
  • Loading branch information
lsun100 committed Mar 23, 2020
1 parent c76e633 commit afc9cb3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/rshim.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static int rshim_fd_full_write(int fd, void *data, int len)
void rshim_work_signal(rshim_backend_t *bd)
{
if (__sync_bool_compare_and_swap(&bd->work_pending, false, true))
rshim_fd_full_write(rshim_work_fd[1], &bd, sizeof(bd));
rshim_fd_full_write(rshim_work_fd[1], &bd->index, sizeof(bd->index));
}

/*
Expand Down Expand Up @@ -2090,7 +2090,7 @@ bool rshim_allow_device(const char *devname)

static void rshim_main(int argc, char *argv[])
{
int i, fd, num, rc, epoll_fd, timer_fd;
int i, fd, num, rc, epoll_fd, timer_fd, index;
#ifdef __FreeBSD__
const int MAXEVENTS = 16;
#else
Expand Down Expand Up @@ -2206,9 +2206,12 @@ static void rshim_main(int argc, char *argv[])
rshim_fd_full_read(timer_fd, &res, sizeof(res));
rshim_timer_run();
} else if (fd == rshim_work_fd[0]) {
rc = rshim_fd_full_read(rshim_work_fd[0], &bd, sizeof(bd));
if (rc == sizeof(bd))
rshim_work_handler(bd);
rc = rshim_fd_full_read(rshim_work_fd[0], &index, sizeof(index));
if (rc == sizeof(index)) {
bd = rshim_devs[index];
if (bd)
rshim_work_handler(bd);
}
continue;
} else {
uint8_t tmp;
Expand Down
2 changes: 1 addition & 1 deletion src/rshim_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int rshim_if_open(char *ifname, int index)

memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);

rc = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (rc < 0) {
Expand Down

0 comments on commit afc9cb3

Please sign in to comment.