[10/25] event/cnxk: replace snprintf with strlcpy

Message ID 20230601150106.18375-11-stephen@networkplumber.org (mailing list archive)
State Rejected
Delegated to: Thomas Monjalon
Headers
Series replace snprintf with strlcpy |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger June 1, 2023, 3 p.m. UTC
  Suggested by devtools/cocci/strlcpy-with-header.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/event/cnxk/cnxk_eventdev_stats.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
  

Patch

diff --git a/drivers/event/cnxk/cnxk_eventdev_stats.c b/drivers/event/cnxk/cnxk_eventdev_stats.c
index a8a87a06e43e..e18d24815f81 100644
--- a/drivers/event/cnxk/cnxk_eventdev_stats.c
+++ b/drivers/event/cnxk/cnxk_eventdev_stats.c
@@ -246,15 +246,14 @@  cnxk_sso_xstats_get_names(const struct rte_eventdev *event_dev,
 	unsigned int i;
 
 	for (i = 0; i < CNXK_SSO_NUM_HWS_XSTATS; i++) {
-		snprintf(xstats_names_copy[i].name,
-			 sizeof(xstats_names_copy[i].name), "%s",
-			 sso_hws_xstats[i].name);
+		strlcpy(xstats_names_copy[i].name, sso_hws_xstats[i].name,
+			sizeof(xstats_names_copy[i].name));
 	}
 
 	for (; i < CNXK_SSO_NUM_XSTATS; i++) {
-		snprintf(xstats_names_copy[i].name,
-			 sizeof(xstats_names_copy[i].name), "%s",
-			 sso_hwgrp_xstats[i - CNXK_SSO_NUM_HWS_XSTATS].name);
+		strlcpy(xstats_names_copy[i].name,
+			sso_hwgrp_xstats[i - CNXK_SSO_NUM_HWS_XSTATS].name,
+			sizeof(xstats_names_copy[i].name));
 	}
 
 	switch (mode) {