From 99d7a72cbcad959e805e8e8b5efb112e9def69c2 Mon Sep 17 00:00:00 2001 From: Marco Varlese Date: Wed, 27 Jun 2018 09:54:44 +0200 Subject: gcc8 and Wstringop-truncation gcc8 introduced a new warning (Wstringop-truncation) which in our case is being treated as error. Disabling the warning globally might introduce bugs related to string truncation which are not desired by the developer (e.g. bug). Instead, this patch disables the warning only for those occurences which have been verified to be non-bugs but the desired behaviour as per developer will. Change-Id: I0f04ff6b4fad44061e80a65af633fd7e0148a0c5 Signed-off-by: Marco Varlese --- src/vlib/linux/pci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/vlib/linux') diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c index 11480ca081c..7cadb1378ec 100644 --- a/src/vlib/linux/pci.c +++ b/src/vlib/linux/pci.c @@ -442,7 +442,8 @@ vlib_pci_bind_to_uio (vlib_pci_addr_t * addr, char *uio_drv_name) memset (&ifr, 0, sizeof ifr); memset (&drvinfo, 0, sizeof drvinfo); ifr.ifr_data = (char *) &drvinfo; - strncpy (ifr.ifr_name, e->d_name, IFNAMSIZ - 1); + strncpy (ifr.ifr_name, e->d_name, sizeof (ifr.ifr_name)); + ifr.ifr_name[ARRAY_LEN (ifr.ifr_name) - 1] = '\0'; drvinfo.cmd = ETHTOOL_GDRVINFO; if (ioctl (fd, SIOCETHTOOL, &ifr) < 0) { @@ -457,7 +458,8 @@ vlib_pci_bind_to_uio (vlib_pci_addr_t * addr, char *uio_drv_name) continue; memset (&ifr, 0, sizeof (ifr)); - strncpy (ifr.ifr_name, e->d_name, IFNAMSIZ - 1); + strncpy (ifr.ifr_name, e->d_name, sizeof (ifr.ifr_name)); + ifr.ifr_name[ARRAY_LEN (ifr.ifr_name) - 1] = '\0'; if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0) { error = clib_error_return_unix (0, "ioctl fetch intf %s flags", -- cgit 1.2.3-korg