[15/25] net/cxgbe: replace snprintf with strlcpy

Message ID 20230601150106.18375-16-stephen@networkplumber.org (mailing list archive)
State Rejected, archived
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/net/cxgbe/cxgbe_ethdev.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
  

Patch

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 45bbeaef0ceb..a00fa6051344 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -928,9 +928,8 @@  static int cxgbe_dev_xstats(struct rte_eth_dev *dev,
 	count = 0;
 	for (i = 0; i < nstats; i++, count++) {
 		if (xstats_names != NULL)
-			snprintf(xstats_names[count].name,
-				 sizeof(xstats_names[count].name),
-				 "%s", xstats_str[i].name);
+			strlcpy(xstats_names[count].name, xstats_str[i].name,
+				sizeof(xstats_names[count].name));
 		if (xstats != NULL) {
 			stats_ptr = RTE_PTR_ADD(&ps,
 						xstats_str[i].offset);
@@ -1043,8 +1042,8 @@  int cxgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 			ret = -EINVAL;
 			goto out_err;
 		}
-		rte_strlcpy(xnames[i].name, xnames_copy[ids[i]].name,
-			    sizeof(xnames[i].name));
+		strlcpy(xnames[i].name, xnames_copy[ids[i]].name,
+			sizeof(xnames[i].name));
 	}
 
 	ret = n;