Skip to content

Commit

Permalink
Fix several compiling warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Liming Sun <[email protected]>
  • Loading branch information
lsun100 committed Apr 14, 2020
1 parent 257a860 commit b99dcd4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions 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) - 1);
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);

rc = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (rc < 0) {
Expand Down Expand Up @@ -144,7 +144,7 @@ static int rshim_if_open(char *ifname, int index)
char temp[sizeof(ifr.ifr_name)];

memcpy(temp, ifr.ifr_name, sizeof(temp));
strncpy(ifr.ifr_name, ifname, sizeof(temp));
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);

/* cleanup old device */
if (ioctl(s, SIOCIFDESTROY, &ifr) < 0) {
Expand All @@ -154,7 +154,7 @@ static int rshim_if_open(char *ifname, int index)
return -1;
}

strncpy(ifr.ifr_name, temp, sizeof(temp));
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", temp);

/* try to rename device again */
if (ioctl(s, SIOCSIFNAME, &ifr) < 0) {
Expand All @@ -165,7 +165,7 @@ static int rshim_if_open(char *ifname, int index)
}
}

strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);

ifr.ifr_mtu = ETH_PKT_SIZE;
if (ioctl(s, SIOCSIFMTU, &ifr) < 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/rshim_pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ static int rshim_pcie_probe(struct pci_dev *pci_dev)
#ifdef __linux__
char path[256];
#endif
int ret;
int ret = 0;

snprintf(dev_name, sizeof(dev_name) - 1, "pcie-%02x:%02x.%x",
pci_dev->bus, pci_dev->dev, pci_dev->func);
Expand Down Expand Up @@ -445,7 +445,7 @@ int rshim_pcie_enable(void *dev)
#ifdef __linux__
struct pci_dev *pci_dev = (struct pci_dev *)dev;
char name[256];
int fd, rc;
int fd, rc = 0;

snprintf(name, sizeof(name), "%s/%04x:%02x:%02x.%1u/enable",
SYS_BUS_PCI, pci_dev->domain, pci_dev->bus,
Expand Down

0 comments on commit b99dcd4

Please sign in to comment.