[16/25] net/dpaa*: replace snprintf with strlcpy

Message ID 20230601150106.18375-17-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/net/dpaa/dpaa_ethdev.c   | 8 ++++----
 drivers/net/dpaa2/dpaa2_ethdev.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
  

Comments

Hemant Agrawal June 2, 2023, 4:24 a.m. UTC | #1
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
  

Patch

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index a6c86113d125..0076a531005b 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -620,8 +620,8 @@  dpaa_dev_rx_burst_mode_get(struct rte_eth_dev *dev,
 	/* Update Rx offload info */
 	for (i = 0; i < RTE_DIM(rx_offload_map); i++) {
 		if (eth_conf->rxmode.offloads & rx_offload_map[i].flags) {
-			snprintf(mode->info, sizeof(mode->info), "%s",
-				rx_offload_map[i].output);
+			strlcpy(mode->info, rx_offload_map[i].output,
+				sizeof(mode->info));
 			ret = 0;
 			break;
 		}
@@ -654,8 +654,8 @@  dpaa_dev_tx_burst_mode_get(struct rte_eth_dev *dev,
 	/* Update Tx offload info */
 	for (i = 0; i < RTE_DIM(tx_offload_map); i++) {
 		if (eth_conf->txmode.offloads & tx_offload_map[i].flags) {
-			snprintf(mode->info, sizeof(mode->info), "%s",
-				tx_offload_map[i].output);
+			strlcpy(mode->info, tx_offload_map[i].output,
+				sizeof(mode->info));
 			ret = 0;
 			break;
 		}
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 679f33ae1a08..baa1c2d1ea0f 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -313,8 +313,8 @@  dpaa2_dev_rx_burst_mode_get(struct rte_eth_dev *dev,
 	/* Update Rx offload info */
 	for (i = 0; i < RTE_DIM(rx_offload_map); i++) {
 		if (eth_conf->rxmode.offloads & rx_offload_map[i].flags) {
-			snprintf(mode->info, sizeof(mode->info), "%s",
-				rx_offload_map[i].output);
+			strlcpy(mode->info, rx_offload_map[i].output,
+				sizeof(mode->info));
 			ret = 0;
 			break;
 		}
@@ -348,8 +348,8 @@  dpaa2_dev_tx_burst_mode_get(struct rte_eth_dev *dev,
 	/* Update Tx offload info */
 	for (i = 0; i < RTE_DIM(tx_offload_map); i++) {
 		if (eth_conf->txmode.offloads & tx_offload_map[i].flags) {
-			snprintf(mode->info, sizeof(mode->info), "%s",
-				tx_offload_map[i].output);
+			strlcpy(mode->info, tx_offload_map[i].output,
+				sizeof(mode->info));
 			ret = 0;
 			break;
 		}