Suggested by devtools/cocci/strlcpy-with-header.cocci Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- drivers/common/mlx5/linux/mlx5_common_os.c | 2 +- drivers/common/mlx5/mlx5_common_utils.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index aafff60eeb38..c4ceeccf3825 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -897,7 +897,7 @@ mlx5_get_device_guid(const struct rte_pci_addr *dev, uint8_t *guid, size_t len) } } while (strchr(ptr->d_name, '.') || strchr(ptr->d_name, '_') || strchr(ptr->d_name, 'v')); - snprintf(cur_ifname, sizeof(cur_ifname), "%s", ptr->d_name); + strlcpy(cur_ifname, ptr->d_name, sizeof(cur_ifname)); closedir(dir); snprintf(tmp + strlen(tmp), sizeof(tmp) - strlen(tmp), "/%s/phys_switch_id", cur_ifname); diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c index e69d06878c2e..3e809b409854 100644 --- a/drivers/common/mlx5/mlx5_common_utils.c +++ b/drivers/common/mlx5/mlx5_common_utils.c @@ -49,8 +49,7 @@ mlx5_list_create(const char *name, void *ctx, bool lcores_share, if (!list) return NULL; if (name) - snprintf(list->l_const.name, - sizeof(list->l_const.name), "%s", name); + strlcpy(list->l_const.name, name, sizeof(list->l_const.name)); list->l_const.ctx = ctx; list->l_const.lcores_share = lcores_share; list->l_const.cb_create = cb_create; @@ -422,7 +421,7 @@ mlx5_hlist_create(const char *name, uint32_t size, bool direct_key, return NULL; } if (name) - snprintf(h->l_const.name, sizeof(h->l_const.name), "%s", name); + strlcpy(h->l_const.name, name, sizeof(h->l_const.name)); h->l_const.ctx = ctx; h->l_const.lcores_share = lcores_share; h->l_const.cb_create = cb_create; -- 2.39.2