[24/25] net/qede: replace snprintf with strlcpy

Message ID 20230601150106.18375-25-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/qede/qede_ethdev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
  

Patch

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index a4923670d6ba..7429ec3e8773 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -238,8 +238,8 @@  qede_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	size_t size;
 
 	if (IS_PF(edev))
-		snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s",
-			 QEDE_PMD_FW_VERSION);
+		strlcpy(ver_str, QEDE_PMD_FW_VERSION,
+			QEDE_PMD_DRV_VER_STR_SIZE);
 	else
 		snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%d.%d.%d.%d",
 			 info->fw_major, info->fw_minor,
@@ -374,11 +374,9 @@  static void qede_print_adapter_info(struct rte_eth_dev *dev)
 		  ECORE_IS_BB(edev) ? "BB" : "AH",
 		  'A' + edev->chip_rev,
 		  (int)edev->chip_metal);
-	snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s",
-		 QEDE_PMD_DRV_VERSION);
+	strlcpy(ver_str, QEDE_PMD_DRV_VERSION, QEDE_PMD_DRV_VER_STR_SIZE);
 	DP_INFO(edev, " %-20s: %s\n", "Driver version", ver_str);
-	snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s",
-		 QEDE_PMD_BASE_VERSION);
+	strlcpy(ver_str, QEDE_PMD_BASE_VERSION, QEDE_PMD_DRV_VER_STR_SIZE);
 	DP_INFO(edev, " %-20s: %s\n", "Base version", ver_str);
 	qede_fw_version_get(dev, ver_str, sizeof(ver_str));
 	DP_INFO(edev, " %-20s: %s\n", "Firmware version", ver_str);