[19/25] net/intel: replace snprintf with strlcpy

Message ID 20230601150106.18375-20-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:01 p.m. UTC
  Suggested by devtools/cocci/strlcpy-with-header.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/fm10k/fm10k_ethdev.c | 6 +++---
 drivers/net/i40e/i40e_rxtx.c     | 8 ++++----
 drivers/net/iavf/iavf_ethdev.c   | 6 +++---
 drivers/net/ice/ice_dcf_ethdev.c | 6 +++---
 drivers/net/ice/ice_rxtx.c       | 8 ++++----
 drivers/net/idpf/idpf_ethdev.c   | 6 +++---
 6 files changed, 20 insertions(+), 20 deletions(-)
  

Patch

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 4d3c4c10cfa4..cb8cf1a8a8ea 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1244,9 +1244,9 @@  static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 
 		/* Global stats */
 		for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
-			snprintf(xstats_names[count].name,
-				sizeof(xstats_names[count].name),
-				"%s", fm10k_hw_stats_strings[count].name);
+			strlcpy(xstats_names[count].name,
+				fm10k_hw_stats_strings[count].name,
+				sizeof(xstats_names[count].name));
 			count++;
 		}
 
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 788ffb51c272..54fb9b9c15ec 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -3395,8 +3395,8 @@  i40e_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 
 	for (i = 0; i < RTE_DIM(i40e_rx_burst_infos); ++i) {
 		if (pkt_burst == i40e_rx_burst_infos[i].pkt_burst) {
-			snprintf(mode->info, sizeof(mode->info), "%s",
-				 i40e_rx_burst_infos[i].info);
+			strlcpy(mode->info, i40e_rx_burst_infos[i].info,
+				sizeof(mode->info));
 			ret = 0;
 			break;
 		}
@@ -3526,8 +3526,8 @@  i40e_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 
 	for (i = 0; i < RTE_DIM(i40e_tx_burst_infos); ++i) {
 		if (pkt_burst == i40e_tx_burst_infos[i].pkt_burst) {
-			snprintf(mode->info, sizeof(mode->info), "%s",
-				 i40e_tx_burst_infos[i].info);
+			strlcpy(mode->info, i40e_tx_burst_infos[i].info,
+				sizeof(mode->info));
 			ret = 0;
 			break;
 		}
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index f6d68403ce71..f3474f6faccb 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1802,9 +1802,9 @@  static int iavf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 
 	if (xstats_names != NULL)
 		for (i = 0; i < IAVF_NB_XSTATS; i++) {
-			snprintf(xstats_names[i].name,
-				sizeof(xstats_names[i].name),
-				"%s", rte_iavf_stats_strings[i].name);
+			strlcpy(xstats_names[i].name,
+				rte_iavf_stats_strings[i].name,
+				sizeof(xstats_names[i].name));
 		}
 	return IAVF_NB_XSTATS;
 }
diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index dcbf2af5b039..ea5296b54246 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1549,9 +1549,9 @@  static int ice_dcf_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 
 	if (xstats_names != NULL)
 		for (i = 0; i < ICE_DCF_NB_XSTATS; i++) {
-			snprintf(xstats_names[i].name,
-				sizeof(xstats_names[i].name),
-				"%s", rte_ice_dcf_stats_strings[i].name);
+			strlcpy(xstats_names[i].name,
+				rte_ice_dcf_stats_strings[i].name,
+				sizeof(xstats_names[i].name));
 		}
 	return ICE_DCF_NB_XSTATS;
 }
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 0ea0045836cc..bde52f7532fb 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -3605,8 +3605,8 @@  ice_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 
 	for (i = 0; i < RTE_DIM(ice_rx_burst_infos); ++i) {
 		if (pkt_burst == ice_rx_burst_infos[i].pkt_burst) {
-			snprintf(mode->info, sizeof(mode->info), "%s",
-				 ice_rx_burst_infos[i].info);
+			strlcpy(mode->info, ice_rx_burst_infos[i].info,
+				sizeof(mode->info));
 			ret = 0;
 			break;
 		}
@@ -3846,8 +3846,8 @@  ice_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 
 	for (i = 0; i < RTE_DIM(ice_tx_burst_infos); ++i) {
 		if (pkt_burst == ice_tx_burst_infos[i].pkt_burst) {
-			snprintf(mode->info, sizeof(mode->info), "%s",
-				 ice_tx_burst_infos[i].info);
+			strlcpy(mode->info, ice_tx_burst_infos[i].info,
+				sizeof(mode->info));
 			ret = 0;
 			break;
 		}
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index e02ec2ec5ace..39c9edbb3c19 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -384,9 +384,9 @@  static int idpf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 
 	if (xstats_names)
 		for (i = 0; i < IDPF_NB_XSTATS; i++) {
-			snprintf(xstats_names[i].name,
-				 sizeof(xstats_names[i].name),
-				 "%s", rte_idpf_stats_strings[i].name);
+			strlcpy(xstats_names[i].name,
+				rte_idpf_stats_strings[i].name,
+				sizeof(xstats_names[i].name));
 		}
 	return IDPF_NB_XSTATS;
 }