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>
Subject: [PATCH 1/2] lib: replace rte_strlcpy() with strlcpy()
Date: Wed, 31 May 2023 15:05:32 -0700	[thread overview]
Message-ID: <20230531220533.29910-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20230531220533.29910-1-stephen@networkplumber.org>

The function rte_strlcpy is intended to be a platform specific
wrapper function and only used where necessary. Prefer using
the OS supplied strlcpy() if available.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_memzone.c |  2 +-
 lib/fib/rte_fib.c                   |  2 +-
 lib/fib/rte_fib6.c                  |  2 +-
 lib/hash/rte_thash.c                |  4 +--
 lib/mempool/rte_mempool.c           |  2 +-
 lib/mldev/mldev_utils.c             | 40 ++++++++++++++---------------
 lib/rib/rte_rib.c                   |  2 +-
 lib/rib/rte_rib6.c                  |  2 +-
 8 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c
index a9cd91ffeac3..802a7f6a3f6b 100644
--- a/lib/eal/common/eal_common_memzone.c
+++ b/lib/eal/common/eal_common_memzone.c
@@ -274,7 +274,7 @@ rte_memzone_free(const struct rte_memzone *mz)
 	if (mz == NULL)
 		return -EINVAL;
 
-	rte_strlcpy(name, mz->name, RTE_MEMZONE_NAMESIZE);
+	strlcpy(name, mz->name, RTE_MEMZONE_NAMESIZE);
 	mcfg = rte_eal_get_configuration()->mem_config;
 	arr = &mcfg->memzones;
 
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 0c3b20e00a5a..067268ba507d 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -208,7 +208,7 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 		goto free_te;
 	}
 
-	rte_strlcpy(fib->name, name, sizeof(fib->name));
+	strlcpy(fib->name, name, sizeof(fib->name));
 	fib->rib = rib;
 	fib->type = conf->type;
 	fib->def_nh = conf->default_nh;
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 28c69b38999f..9c6401f71018 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -209,7 +209,7 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 		goto free_te;
 	}
 
-	rte_strlcpy(fib->name, name, sizeof(fib->name));
+	strlcpy(fib->name, name, sizeof(fib->name));
 	fib->rib = rib;
 	fib->type = conf->type;
 	fib->def_nh = conf->default_nh;
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..5a4e8d4a0dc3 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -255,7 +255,7 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 		goto free_te;
 	}
 
-	rte_strlcpy(ctx->name, name, sizeof(ctx->name));
+	strlcpy(ctx->name, name, sizeof(ctx->name));
 	ctx->key_len = key_len;
 	ctx->reta_sz_log = reta_sz;
 	LIST_INIT(&ctx->head);
@@ -574,7 +574,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len,
 	if (ent == NULL)
 		return -ENOMEM;
 
-	rte_strlcpy(ent->name, name, sizeof(ent->name));
+	strlcpy(ent->name, name, sizeof(ent->name));
 	ent->offset = start;
 	ent->len = end - start;
 	ent->tuple_offset = offset;
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index cf5dea2304a7..5c0afa2d7060 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -1546,7 +1546,7 @@ mempool_handle_info(const char *cmd __rte_unused, const char *params,
 	if (!params || strlen(params) == 0)
 		return -EINVAL;
 
-	rte_strlcpy(name, params, RTE_MEMZONE_NAMESIZE);
+	strlcpy(name, params, RTE_MEMZONE_NAMESIZE);
 
 	rte_tel_data_start_dict(d);
 	mp_arg.pool_name = name;
diff --git a/lib/mldev/mldev_utils.c b/lib/mldev/mldev_utils.c
index d2442b123b8c..054db2efba80 100644
--- a/lib/mldev/mldev_utils.c
+++ b/lib/mldev/mldev_utils.c
@@ -50,40 +50,40 @@ rte_ml_io_type_to_str(enum rte_ml_io_type type, char *str, int len)
 {
 	switch (type) {
 	case RTE_ML_IO_TYPE_UNKNOWN:
-		rte_strlcpy(str, "unknown", len);
+		strlcpy(str, "unknown", len);
 		break;
 	case RTE_ML_IO_TYPE_INT8:
-		rte_strlcpy(str, "int8", len);
+		strlcpy(str, "int8", len);
 		break;
 	case RTE_ML_IO_TYPE_UINT8:
-		rte_strlcpy(str, "uint8", len);
+		strlcpy(str, "uint8", len);
 		break;
 	case RTE_ML_IO_TYPE_INT16:
-		rte_strlcpy(str, "int16", len);
+		strlcpy(str, "int16", len);
 		break;
 	case RTE_ML_IO_TYPE_UINT16:
-		rte_strlcpy(str, "uint16", len);
+		strlcpy(str, "uint16", len);
 		break;
 	case RTE_ML_IO_TYPE_INT32:
-		rte_strlcpy(str, "int32", len);
+		strlcpy(str, "int32", len);
 		break;
 	case RTE_ML_IO_TYPE_UINT32:
-		rte_strlcpy(str, "uint32", len);
+		strlcpy(str, "uint32", len);
 		break;
 	case RTE_ML_IO_TYPE_FP8:
-		rte_strlcpy(str, "float8", len);
+		strlcpy(str, "float8", len);
 		break;
 	case RTE_ML_IO_TYPE_FP16:
-		rte_strlcpy(str, "float16", len);
+		strlcpy(str, "float16", len);
 		break;
 	case RTE_ML_IO_TYPE_FP32:
-		rte_strlcpy(str, "float32", len);
+		strlcpy(str, "float32", len);
 		break;
 	case RTE_ML_IO_TYPE_BFLOAT16:
-		rte_strlcpy(str, "bfloat16", len);
+		strlcpy(str, "bfloat16", len);
 		break;
 	default:
-		rte_strlcpy(str, "invalid", len);
+		strlcpy(str, "invalid", len);
 	}
 }
 
@@ -92,27 +92,27 @@ rte_ml_io_format_to_str(enum rte_ml_io_format format, char *str, int len)
 {
 	switch (format) {
 	case RTE_ML_IO_FORMAT_NCHW:
-		rte_strlcpy(str, "NCHW", len);
+		strlcpy(str, "NCHW", len);
 		break;
 	case RTE_ML_IO_FORMAT_NHWC:
-		rte_strlcpy(str, "NHWC", len);
+		strlcpy(str, "NHWC", len);
 		break;
 	case RTE_ML_IO_FORMAT_CHWN:
-		rte_strlcpy(str, "CHWN", len);
+		strlcpy(str, "CHWN", len);
 		break;
 	case RTE_ML_IO_FORMAT_3D:
-		rte_strlcpy(str, "3D", len);
+		strlcpy(str, "3D", len);
 		break;
 	case RTE_ML_IO_FORMAT_2D:
-		rte_strlcpy(str, "Matrix", len);
+		strlcpy(str, "Matrix", len);
 		break;
 	case RTE_ML_IO_FORMAT_1D:
-		rte_strlcpy(str, "Vector", len);
+		strlcpy(str, "Vector", len);
 		break;
 	case RTE_ML_IO_FORMAT_SCALAR:
-		rte_strlcpy(str, "Scalar", len);
+		strlcpy(str, "Scalar", len);
 		break;
 	default:
-		rte_strlcpy(str, "invalid", len);
+		strlcpy(str, "invalid", len);
 	}
 }
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index 812a2597d117..57837c632bde 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -453,7 +453,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 		goto free_te;
 	}
 
-	rte_strlcpy(rib->name, name, sizeof(rib->name));
+	strlcpy(rib->name, name, sizeof(rib->name));
 	rib->tree = NULL;
 	rib->max_nodes = conf->max_nodes;
 	rib->node_pool = node_pool;
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index ae44281ae105..acb00a4809f1 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -522,7 +522,7 @@ rte_rib6_create(const char *name, int socket_id,
 		goto free_te;
 	}
 
-	rte_strlcpy(rib->name, name, sizeof(rib->name));
+	strlcpy(rib->name, name, sizeof(rib->name));
 	rib->tree = NULL;
 	rib->max_nodes = conf->max_nodes;
 	rib->node_pool = node_pool;
-- 
2.39.2


  reply	other threads:[~2023-05-31 22:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31 22:05 [PATCH 0/2] cleanup use of rte_strlcpy Stephen Hemminger
2023-05-31 22:05 ` Stephen Hemminger [this message]
2023-05-31 22:05 ` [PATCH 2/2] drivers: don't use rte_strlcpy Stephen Hemminger
2023-06-01 10:18 ` [PATCH 0/2] cleanup use of rte_strlcpy Bruce Richardson
2023-06-02 21:46   ` 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=20230531220533.29910-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /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).