drivers/infiniband/hw/mlx4/sysfs.c:360:2: warning: ‘strncpy’ output may be truncated copying 8 bytes from a string of length 31 [-Wstringop-truncation] strncpy(base_name, name, 8); /*till xxxx:yy:*/ ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Qian Cai <cai@xxxxxx> --- drivers/infiniband/hw/mlx4/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c index 752bdd536130..1fa23c358d01 100644 --- a/drivers/infiniband/hw/mlx4/sysfs.c +++ b/drivers/infiniband/hw/mlx4/sysfs.c @@ -357,7 +357,7 @@ static void get_name(struct mlx4_ib_dev *dev, char *name, int i, int max) /* pci_name format is: bus:dev:func -> xxxx:yy:zz.n */ strlcpy(name, pci_name(dev->dev->persist->pdev), max); - strncpy(base_name, name, 8); /*till xxxx:yy:*/ + snprintf(base_name, sizeof(base_name), name); /*till xxxx:yy:*/ base_name[8] = '\0'; /* with no ARI only 3 last bits are used so when the fn is higher than 8 * need to add it to the dev num, so count in the last number will be -- 2.17.2 (Apple Git-113)