[PATCH 04/25] raw/ifpga: replace snprintf with strlcpy
Xu, Rosen
rosen.xu at intel.com
Fri Jun 2 08:04:48 CEST 2023
Hi,
> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org>
> Sent: Thursday, June 1, 2023 11:01 PM
> To: dev at dpdk.org
> Cc: Stephen Hemminger <stephen at networkplumber.org>; Xu, Rosen
> <rosen.xu at intel.com>; Zhang, Tianfei <tianfei.zhang at intel.com>
> Subject: [PATCH 04/25] raw/ifpga: replace snprintf with strlcpy
>
> Suggested by devtools/cocci/strlcpy-with-header.cocci
>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
> drivers/raw/ifpga/afu_pmd_core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/raw/ifpga/afu_pmd_core.c
> b/drivers/raw/ifpga/afu_pmd_core.c
> index 3ab1f47ac1a4..e969897dbe7d 100644
> --- a/drivers/raw/ifpga/afu_pmd_core.c
> +++ b/drivers/raw/ifpga/afu_pmd_core.c
> @@ -16,6 +16,7 @@
> #include <rte_malloc.h>
> #include <rte_memzone.h>
> #include <rte_rawdev_pmd.h>
> +#include <rte_string_fns.h>
>
> #include "afu_pmd_core.h"
>
> @@ -225,7 +226,7 @@ static int afu_shared_data_alloc(const char *name,
> return -EINVAL;
>
> /* name format is afu_?|??:??.? which is unique */
> - snprintf(mz_name, sizeof(mz_name), "%s", name);
> + strlcpy(mz_name, name, sizeof(mz_name));
>
> mz = rte_memzone_lookup(mz_name);
> if (!mz) {
> --
> 2.39.2
Reviewed-by: Rosen Xu <rosen.xu at intel.com>
More information about the dev
mailing list