DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Nicolas Chautru <nicolas.chautru@intel.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: [PATCH 03/25] lib: use strlcpy instead of snprintf
Date: Thu,  1 Jun 2023 08:00:44 -0700	[thread overview]
Message-ID: <20230601150106.18375-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20230601150106.18375-1-stephen@networkplumber.org>

Replace snprintf with strlcpy where possible.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/bbdev/rte_bbdev.c |  2 +-
 lib/ethdev/sff_8636.c | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c
index 581509b5a213..7cc126a0e7be 100644
--- a/lib/bbdev/rte_bbdev.c
+++ b/lib/bbdev/rte_bbdev.c
@@ -212,7 +212,7 @@ rte_bbdev_allocate(const char *name)
 	bbdev->data->dev_id = dev_id;
 	bbdev->state = RTE_BBDEV_INITIALIZED;
 
-	ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name);
+	ret = strlcpy(bbdev->data->name, name, RTE_BBDEV_NAME_MAX_LEN);
 	if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) {
 		rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name);
 		return NULL;
diff --git a/lib/ethdev/sff_8636.c b/lib/ethdev/sff_8636.c
index 6b65f47efedf..a623e0d065d8 100644
--- a/lib/ethdev/sff_8636.c
+++ b/lib/ethdev/sff_8636.c
@@ -203,16 +203,19 @@ static void sff_8636_show_ext_identifier(const uint8_t *data, struct rte_tel_dat
 
 	switch (data[SFF_8636_EXT_ID_OFFSET] & SFF_8636_EXT_ID_EPWR_CLASS_MASK) {
 	case SFF_8636_EXT_ID_PWR_CLASS_LEGACY:
-		snprintf(val_string, sizeof(val_string), "%s", "");
+		strlcpy(val_string, "", sizeof(val_string));
 		break;
 	case SFF_8636_EXT_ID_PWR_CLASS_5:
-		snprintf(val_string, sizeof(val_string), "%s", "4.0W max. Power consumption, ");
+		strlcpy(val_string, "4.0W max. Power consumption, ",
+			sizeof(val_string));
 		break;
 	case SFF_8636_EXT_ID_PWR_CLASS_6:
-		snprintf(val_string, sizeof(val_string), "%s", "4.5W max. Power consumption, ");
+		strlcpy(val_string, "4.5W max. Power consumption, ",
+			sizeof(val_string));
 		break;
 	case SFF_8636_EXT_ID_PWR_CLASS_7:
-		snprintf(val_string, sizeof(val_string), "%s", "5.0W max. Power consumption, ");
+		strlcpy(val_string, "5.0W max. Power consumption, ",
+			sizeof(val_string));
 		break;
 	}
 
-- 
2.39.2


  parent reply	other threads:[~2023-06-01 15:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 15:00 [PATCH 00/25] replace snprintf with strlcpy Stephen Hemminger
2023-06-01 15:00 ` [PATCH 01/25] app: use strlcpy in tests Stephen Hemminger
2023-06-01 15:00 ` [PATCH 02/25] examples: use strlcpy instead of snprintf Stephen Hemminger
2023-06-01 15:00 ` Stephen Hemminger [this message]
2023-06-01 15:00 ` [PATCH 04/25] raw/ifpga: replace snprintf with strlcpy Stephen Hemminger
2023-06-02  6:04   ` Xu, Rosen
2023-06-01 15:00 ` [PATCH 05/25] common/cnxk: replace snprint " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 06/25] common/mlx5: replace snprintf " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 07/25] drivers/gpu: " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 08/25] crypto/ipsec_mb: remove unnecessary snprintf Stephen Hemminger
2023-06-01 15:00 ` [PATCH 09/25] crypto/dpaa_sec: replace snprintf with strlcpy Stephen Hemminger
2023-06-02  4:24   ` Hemant Agrawal
2023-06-01 15:00 ` [PATCH 10/25] event/cnxk: " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 11/25] net/atlantic: " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 12/25] net/axgbe: " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 13/25] net/bnxt: " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 14/25] net/cpfl: " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 15/25] net/cxgbe: " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 16/25] net/dpaa*: " Stephen Hemminger
2023-06-02  4:24   ` Hemant Agrawal
2023-06-01 15:00 ` [PATCH 17/25] net/hinic: replace snptintf " Stephen Hemminger
2023-06-01 15:00 ` [PATCH 18/25] net/hns3: replace snprint " Stephen Hemminger
2023-06-01 15:01 ` [PATCH 19/25] net/intel: replace snprintf " Stephen Hemminger
2023-06-01 15:01 ` [PATCH 20/25] net/ionic: " Stephen Hemminger
2023-06-02  6:05   ` Xu, Rosen
2023-06-01 15:01 ` [PATCH 21/25] net/mlx5: " Stephen Hemminger
2023-06-01 15:01 ` [PATCH 22/25] net/nfp: " Stephen Hemminger
2023-06-05 11:10   ` Niklas Söderlund
2023-06-01 15:01 ` [PATCH 23/25] net/ngbe: " Stephen Hemminger
2023-06-01 15:01 ` [PATCH 24/25] net/qede: " Stephen Hemminger
2023-06-01 15:01 ` [PATCH 25/25] net/txgbe: " Stephen Hemminger
2023-06-02 20:01 ` [PATCH 00/25] " Tyler Retzlaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230601150106.18375-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=nicolas.chautru@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).