[PATCH] net/mlx5: fix build with GCC 12 and ASan
Slava Ovsiienko
viacheslavo at nvidia.com
Tue Mar 14 14:00:02 CET 2023
Hi, David
Thank you for the fix.
I see the quite similar strncpy() usage in mlx5_xstats_get_names() routine.
Does compiler complain about?
With best regards,
Slava
> -----Original Message-----
> From: David Marchand <david.marchand at redhat.com>
> Sent: четверг, 9 марта 2023 г. 11:03
> To: dev at dpdk.org
> Cc: stable at dpdk.org; Matan Azrad <matan at nvidia.com>; Slava Ovsiienko
> <viacheslavo at nvidia.com>
> Subject: [PATCH] net/mlx5: fix build with GCC 12 and ASan
>
> Building with gcc 12 and ASan raises this warning:
>
> ../drivers/net/mlx5/mlx5_txpp.c: In function ‘mlx5_txpp_xstats_get_names’:
> ../drivers/net/mlx5/mlx5_txpp.c:1066:25: error: ‘strncpy’ specified bound
> 64 equals destination size [-Werror=stringop-truncation]
> 1066 | strncpy(xstats_names[i + n_used].name,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1067 | mlx5_txpp_stat_names[i],
> | ~~~~~~~~~~~~~~~~~~~~~~~~
> 1068 | RTE_ETH_XSTATS_NAME_SIZE);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> Prefer strlcpy.
>
> Fixes: 3b025c0ca425 ("net/mlx5: provide send scheduling error statistics")
> Cc: stable at dpdk.org
>
> Signed-off-by: David Marchand <david.marchand at redhat.com>
> ---
> drivers/net/mlx5/mlx5_txpp.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
> index 63d98dbde9..0e1da1d5f5 100644
> --- a/drivers/net/mlx5/mlx5_txpp.c
> +++ b/drivers/net/mlx5/mlx5_txpp.c
> @@ -1063,11 +1063,9 @@ int mlx5_txpp_xstats_get_names(struct
> rte_eth_dev *dev __rte_unused,
>
> if (n >= n_used + n_txpp && xstats_names) {
> for (i = 0; i < n_txpp; ++i) {
> - strncpy(xstats_names[i + n_used].name,
> + strlcpy(xstats_names[i + n_used].name,
> mlx5_txpp_stat_names[i],
> RTE_ETH_XSTATS_NAME_SIZE);
> - xstats_names[i + n_used].name
> - [RTE_ETH_XSTATS_NAME_SIZE - 1] =
> 0;
> }
> }
> return n_used + n_txpp;
> --
> 2.39.2
More information about the dev
mailing list