Skip to content

Commit

Permalink
RDMA/usnic: Suppress a compiler warning
Browse files Browse the repository at this point in the history
This patch avoids that the following compiler warning is reported when
building with gcc 8 and W=1:

drivers/infiniband/hw/usnic/usnic_fwd.c:95:2: warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 20 [-Wstringop-truncation]
  strncpy(ufdev->name, netdev_name(ufdev->netdev),
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sizeof(ufdev->name) - 1);
    ~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Bart Van Assche <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
KAGA-KOKO authored and jgunthorpe committed Jul 26, 2018
1 parent 5d85a82 commit 7cfcc71
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/infiniband/hw/usnic/usnic_fwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ struct usnic_fwd_dev *usnic_fwd_dev_alloc(struct pci_dev *pdev)
ufdev->pdev = pdev;
ufdev->netdev = pci_get_drvdata(pdev);
spin_lock_init(&ufdev->lock);
strncpy(ufdev->name, netdev_name(ufdev->netdev),
sizeof(ufdev->name) - 1);
BUILD_BUG_ON(sizeof(ufdev->name) != sizeof(ufdev->netdev->name));
strcpy(ufdev->name, ufdev->netdev->name);

return ufdev;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/usnic/usnic_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct usnic_fwd_dev {
char mac[ETH_ALEN];
unsigned int mtu;
__be32 inaddr;
char name[IFNAMSIZ+1];
char name[IFNAMSIZ];
};

struct usnic_fwd_flow {
Expand Down

0 comments on commit 7cfcc71

Please sign in to comment.