[v2] kni: fix build with gcc 8.1
Checks
Context |
Check |
Description |
ci/Intel-compilation |
fail
|
apply issues
|
Commit Message
Error observed when CONFIG_RTE_KNI_KMOD_ETHTOOL config option is
enabled.
build error:
In function ‘strncpy’,
inlined from ‘igb_get_drvinfo’ at
.../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2:
.../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output
may be truncated copying 31 bytes from a string of length 42
[-Werror=stringop-truncation]
return __builtin_strncpy(p, q, size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixed by using strlcpy instead of strncpy.
adapter->fw_version size kept same because of
c3698192940c ("kni: fix build with gcc 7.1")
Also next line strncpy usage replaced with strlcpy while arround.
Fixes: c3698192940c ("kni: fix build with gcc 7.1")
Cc: stable@dpdk.org
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
v2:
* used strlcpy instead of strncpy
* Updated strncpy usage in next line to strlcpy too
* Added fixes line
---
kernel/linux/kni/ethtool/igb/igb_ethtool.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
2.17.1
Comments
26/06/2018 11:02, Ferruh Yigit:
> --- a/kernel/linux/kni/ethtool/igb/igb_ethtool.c
> +++ b/kernel/linux/kni/ethtool/igb/igb_ethtool.c
> @@ -811,9 +811,10 @@ static void igb_get_drvinfo(struct net_device *netdev,
> strncpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver) - 1);
> strncpy(drvinfo->version, igb_driver_version, sizeof(drvinfo->version) - 1);
> - strncpy(drvinfo->fw_version, adapter->fw_version,
> - sizeof(drvinfo->fw_version) - 1);
There is a leading space before the minus of first line.
b/kernel/linux/kni/ethtool/igb/igb_ethtool.c
@@ -811,9 +811,10 @@ static void igb_get_drvinfo(struct net_device *netdev,
strncpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver) - 1);
strncpy(drvinfo->version, igb_driver_version, sizeof(drvinfo->version) - 1);
- strncpy(drvinfo->fw_version, adapter->fw_version,
- sizeof(drvinfo->fw_version) - 1);
- strncpy(drvinfo->bus_info, pci_name(adapter->pdev), sizeof(drvinfo->bus_info) -1);
+ strlcpy(drvinfo->fw_version, adapter->fw_version,
+ sizeof(drvinfo->fw_version));
+ strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
+ sizeof(drvinfo->bus_info));
drvinfo->n_stats = IGB_STATS_LEN;
drvinfo->testinfo_len = IGB_TEST_LEN;
drvinfo->regdump_len = igb_get_regs_len(netdev);
--