* [PATCH 0/2] mempool: add rte_errno, and turn functions into single-exit ones
@ 2025-01-19 17:46 Ariel Otilibili
2025-01-19 17:46 ` [PATCH 1/2] mempool: add rte_errno in rte_mempool_set_ops_byname Ariel Otilibili
2025-01-19 17:46 ` [PATCH 2/2] mempool: turn functions into single-exit ones Ariel Otilibili
0 siblings, 2 replies; 3+ messages in thread
From: Ariel Otilibili @ 2025-01-19 17:46 UTC (permalink / raw)
To: dev
Cc: stable, Thomas Monjalon, David Marchand, Ariel Otilibili,
Andrew Rybchenko, Morten Brørup
Hello,
This series is for BugZilla ID 1559.
rte_mempool_set_ops_byname() did not set rte_errno for error exit. As well, other functions did not consistently set the variable.
For avoiding that, they are turned into single-exit functions.
Thank you,
Ariel Otilibili (2):
mempool: add rte_errno in rte_mempool_set_ops_byname
mempool: turn functions into single-exit ones
lib/mempool/rte_mempool_ops.c | 44 ++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 11 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] mempool: add rte_errno in rte_mempool_set_ops_byname
2025-01-19 17:46 [PATCH 0/2] mempool: add rte_errno, and turn functions into single-exit ones Ariel Otilibili
@ 2025-01-19 17:46 ` Ariel Otilibili
2025-01-19 17:46 ` [PATCH 2/2] mempool: turn functions into single-exit ones Ariel Otilibili
1 sibling, 0 replies; 3+ messages in thread
From: Ariel Otilibili @ 2025-01-19 17:46 UTC (permalink / raw)
To: dev
Cc: stable, Thomas Monjalon, David Marchand, Ariel Otilibili,
Andrew Rybchenko, Morten Brørup
rte_errno is not set for error exits. For the scenario described in
BugZilla ID 1559, rte_mempool_create_empty() calls
rte_mempool_set_ops_byname(), but does not set as well the proper
rte_errno.
rte_errno is now set in rte_mempool_set_ops_byname(); from there it
cascades down to the calling function.
Bugzilla ID: 1559
Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>
---
lib/mempool/rte_mempool_ops.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 1b33380259b3..b5c68ac61b67 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -169,8 +169,10 @@ rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
unsigned i;
/* too late, the mempool is already populated. */
- if (mp->flags & RTE_MEMPOOL_F_POOL_CREATED)
- return -EEXIST;
+ if (mp->flags & RTE_MEMPOOL_F_POOL_CREATED) {
+ rte_errno = EEXIST;
+ return -rte_errno;
+ }
for (i = 0; i < rte_mempool_ops_table.num_ops; i++) {
if (!strcmp(name,
@@ -180,8 +182,10 @@ rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
}
}
- if (ops == NULL)
- return -EINVAL;
+ if (ops == NULL) {
+ rte_errno = EINVAL;
+ return -rte_errno;
+ }
mp->ops_index = i;
mp->pool_config = pool_config;
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] mempool: turn functions into single-exit ones
2025-01-19 17:46 [PATCH 0/2] mempool: add rte_errno, and turn functions into single-exit ones Ariel Otilibili
2025-01-19 17:46 ` [PATCH 1/2] mempool: add rte_errno in rte_mempool_set_ops_byname Ariel Otilibili
@ 2025-01-19 17:46 ` Ariel Otilibili
1 sibling, 0 replies; 3+ messages in thread
From: Ariel Otilibili @ 2025-01-19 17:46 UTC (permalink / raw)
To: dev
Cc: stable, Thomas Monjalon, David Marchand, Ariel Otilibili,
Andrew Rybchenko, Morten Brørup
Some functions did not set rte_errno; for avoiding that, they are turned
into single-exit ones.
Bugzilla ID: 1559
Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>
---
lib/mempool/rte_mempool_ops.c | 38 ++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index b5c68ac61b67..bf4328645196 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -33,7 +33,9 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
rte_spinlock_unlock(&rte_mempool_ops_table.sl);
RTE_MEMPOOL_LOG(ERR,
"Maximum number of mempool ops structs exceeded");
- return -ENOSPC;
+ rte_errno = ENOSPC;
+ ops_index = -rte_errno;
+ goto out;
}
if (h->alloc == NULL || h->enqueue == NULL ||
@@ -41,7 +43,9 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
rte_spinlock_unlock(&rte_mempool_ops_table.sl);
RTE_MEMPOOL_LOG(ERR,
"Missing callback while registering mempool ops");
- return -EINVAL;
+ rte_errno = -EINVAL;
+ ops_index = -rte_errno;
+ goto out;
}
if (strlen(h->name) >= sizeof(ops->name) - 1) {
@@ -49,7 +53,8 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
RTE_MEMPOOL_LOG(DEBUG, "%s(): mempool_ops <%s>: name too long",
__func__, h->name);
rte_errno = EEXIST;
- return -EEXIST;
+ ops_index = -rte_errno;
+ goto out;
}
ops_index = rte_mempool_ops_table.num_ops++;
@@ -67,6 +72,7 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
rte_spinlock_unlock(&rte_mempool_ops_table.sl);
+out:
return ops_index;
}
@@ -151,12 +157,19 @@ rte_mempool_ops_get_info(const struct rte_mempool *mp,
struct rte_mempool_info *info)
{
struct rte_mempool_ops *ops;
+ int ret;
ops = rte_mempool_get_ops(mp->ops_index);
- if (ops->get_info == NULL)
- return -ENOTSUP;
- return ops->get_info(mp, info);
+ if (ops->get_info == NULL) {
+ rte_errno = ENOTSUP;
+ ret = -rte_errno;
+ goto out;
+ }
+ ret = ops->get_info(mp, info);
+
+out:
+ return ret;
}
@@ -166,12 +179,14 @@ rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
void *pool_config)
{
struct rte_mempool_ops *ops = NULL;
+ int ret = 0;
unsigned i;
/* too late, the mempool is already populated. */
if (mp->flags & RTE_MEMPOOL_F_POOL_CREATED) {
rte_errno = EEXIST;
- return -rte_errno;
+ ret = -rte_errno;
+ goto out;
}
for (i = 0; i < rte_mempool_ops_table.num_ops; i++) {
@@ -182,13 +197,16 @@ rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
}
}
- if (ops == NULL) {
+ if (!ops) {
rte_errno = EINVAL;
- return -rte_errno;
+ ret = -rte_errno;
+ goto out;
}
mp->ops_index = i;
mp->pool_config = pool_config;
rte_mempool_trace_set_ops_byname(mp, name, pool_config);
- return 0;
+
+out:
+ return ret;
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-19 17:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-19 17:46 [PATCH 0/2] mempool: add rte_errno, and turn functions into single-exit ones Ariel Otilibili
2025-01-19 17:46 ` [PATCH 1/2] mempool: add rte_errno in rte_mempool_set_ops_byname Ariel Otilibili
2025-01-19 17:46 ` [PATCH 2/2] mempool: turn functions into single-exit ones Ariel Otilibili
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).