* [PATCH 1/2] lib: replace rte_strlcpy() with strlcpy()
2023-05-31 22:05 [PATCH 0/2] cleanup use of rte_strlcpy Stephen Hemminger
@ 2023-05-31 22:05 ` Stephen Hemminger
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
2 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2023-05-31 22:05 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] drivers: don't use rte_strlcpy
2023-05-31 22:05 [PATCH 0/2] cleanup use of rte_strlcpy Stephen Hemminger
2023-05-31 22:05 ` [PATCH 1/2] lib: replace rte_strlcpy() with strlcpy() Stephen Hemminger
@ 2023-05-31 22:05 ` Stephen Hemminger
2023-06-01 10:18 ` [PATCH 0/2] cleanup use of rte_strlcpy Bruce Richardson
2 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2023-05-31 22:05 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Prefer using strlcpy over rte_strlcpy.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/common/cnxk/roc_platform.h | 2 +-
drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 2 +-
drivers/net/cnxk/cnxk_ethdev_ops.c | 4 ++--
drivers/net/mlx5/mlx5_testpmd.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 9884398a99d3..921447d735b7 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -215,7 +215,7 @@
#define plt_lcore_id rte_lcore_id
-#define plt_strlcpy rte_strlcpy
+#define plt_strlcpy strlcpy
#define PLT_TEL_INT_VAL RTE_TEL_INT_VAL
#define PLT_TEL_STRING_VAL RTE_TEL_STRING_VAL
diff --git a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
index c71798d7fd66..d766bd079d81 100644
--- a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
+++ b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
@@ -39,7 +39,7 @@ mempool_tel_handle_info(const char *cmd __rte_unused, const char *params,
if (params == NULL || 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/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c
index 068b7c3502c5..9ffc02b591ae 100644
--- a/drivers/net/cnxk/cnxk_ethdev_ops.c
+++ b/drivers/net/cnxk/cnxk_ethdev_ops.c
@@ -753,12 +753,12 @@ cnxk_nix_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version,
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
const char *str = roc_npc_profile_name_get(&dev->npc);
- uint32_t size = strlen(str) + 1;
+ size_t size = strlen(str) + 1;
if (fw_size > size)
fw_size = size;
- rte_strlcpy(fw_version, str, fw_size);
+ strlcpy(fw_version, str, fw_size);
if (fw_size < size)
return size;
diff --git a/drivers/net/mlx5/mlx5_testpmd.c b/drivers/net/mlx5/mlx5_testpmd.c
index 879ea2826ef2..45533fd0e11a 100644
--- a/drivers/net/mlx5/mlx5_testpmd.c
+++ b/drivers/net/mlx5/mlx5_testpmd.c
@@ -179,7 +179,7 @@ mlx5_test_extend_devargs(char *identifier, char *extend)
strerror(errno));
return -1;
}
- rte_strlcpy(un.sun_path, path, sizeof(un.sun_path));
+ strlcpy(un.sun_path, path, sizeof(un.sun_path));
if (connect(socket_fd, (struct sockaddr *)&un, sizeof(un)) < 0) {
TESTPMD_LOG(ERR, "Failed to connect %s: %s\n", un.sun_path,
strerror(errno));
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread