[PATCH 04/25] raw/ifpga: replace snprintf with strlcpy

Stephen Hemminger stephen at networkplumber.org
Thu Jun 1 17:00:45 CEST 2023


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



More information about the dev mailing list