From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 323A146037; Sun, 19 Jan 2025 18:47:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C1D0402F2; Sun, 19 Jan 2025 18:46:57 +0100 (CET) Received: from mail-ed1-f97.google.com (mail-ed1-f97.google.com [209.85.208.97]) by mails.dpdk.org (Postfix) with ESMTP id 72AE5402F2 for ; Sun, 19 Jan 2025 18:46:55 +0100 (CET) Received: by mail-ed1-f97.google.com with SMTP id 4fb4d7f45d1cf-5d3f28881d6so5427769a12.1 for ; Sun, 19 Jan 2025 09:46:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1737308815; x=1737913615; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ngx9vZZ7djfKaam1QiG4I36lBVhFpFJrRsNcXxrjDqg=; b=gLsMbJjEltHV9HkiCka+wQ+AqMf+Xwb0aDsP6f/23sYrnJzpYbocVFkPa+IEdYVYC/ Xzg2yHhdm5EiK3iV5p8ZRJcpTWNEzMqxKWwBpc0xCKtSlRpe/fuIm70qXkfyJCN/7Ifd 8dhA00xPSL45On6ILXbcXQZvjDvcRe2nnz/sKYKabi76Urew71QR/ik6iv/lqdxY+0Kx 7qJs0pJi0HrXQxxVxUbWLuk90WAFRfK/2N7dT1amTwekOKu9e0evXt0zas+atLhqu+ez T69Anv2ciV4FfhLQiQ4QL08miT4lRBRUyOKGrJ8PtwTxC60CmNcu5e2tUxb6W179uQoC qcvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737308815; x=1737913615; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ngx9vZZ7djfKaam1QiG4I36lBVhFpFJrRsNcXxrjDqg=; b=hMM/4BFLpo20m3z0Lh1/Z6kMUq5F42pfM+ePhAeIuXhDd81g+ui0Udbc9BIkTZoAfY vgitRATIJyO5DGYkZB93o/L4uBY8hLD3zAOAx3VcOgk47nn3L8TCnUhK1Ks3OKYnJcbl RaYgQ4uuiBiQG6k2IkWOpnU1tYA2n+JRHlon0FUEoJgN+8vrPc0myK1qZUuu7eCITNid OuyGdW7u38spclSX6sHXKpPJK86ak0VQGLroNfQK3lRS4weMoZZcmNzzSSYw9rQTDyPF atTOzHUqHIuh87KAzjsoMnp5Dbf1Ktj4HRtfVemyPgSQA/e/5v1gVK1FFH3KhP16BG39 Wq8A== X-Gm-Message-State: AOJu0YwvYsoRCP64pAA+yjcFg1h2RznVsvjaKM3HyXlKprWWg5Z+uGk9 zgHdtJ/4tYv48YYPLxUohWGssRWZ4hjiTwOsSyBViGyLYjjdK3QK6ey6k4nMNJ6onqWGmZQrRVe Qemk1Hax6GqcccHrPfVwGK1+FdX6BJzjVAkrBsnMJ X-Gm-Gg: ASbGncsAfLpaE1LTUM0lixiu5xXThCHOhTeftTXhO/Mo1aLvClMFm9FHU1Lzc63yVHk +KdsRNYqo7byJ/hhr7DVPHGJo0zEmq58L8sNA4x4a/s1vF4CO57Zq2iVVHBC3VU3W62slEsHlZa YMWygsBQj7pfWvvB0Ng7uGgu90f40Zy/DZVvBVssif7d6gJYcQk8UXlbjcOEEYBObPfpzXY0Z6v jAZOQ0m62n9A4V2FlU3RtA0JtjpsPd9gIQcSfIwOMaQs012yF5+gIpL54lAJHWH+e4xZYxXJwfG OdOXIbHBh4VcYcvyh5Xd97X9L9vsmHqcN4XQ0Zc= X-Google-Smtp-Source: AGHT+IF6gayOYbAM1dawq7DzT52+ZmfEOceHfziO9eQEbunBII3P/5JxK1YhvsP6cLW0yyNhopqTomvuQMyJ X-Received: by 2002:a05:6402:2742:b0:5d9:f21e:ffd with SMTP id 4fb4d7f45d1cf-5db7d2ff8ccmr26737536a12.15.1737308814886; Sun, 19 Jan 2025 09:46:54 -0800 (PST) Received: from smtpservice.6wind.com ([185.13.181.2]) by smtp-relay.gmail.com with ESMTP id a640c23a62f3a-ab3852d5d5dsm28502866b.231.2025.01.19.09.46.54; Sun, 19 Jan 2025 09:46:54 -0800 (PST) X-Relaying-Domain: 6wind.com Received: from localhost (rainbow.dev.6wind.com [10.17.1.165]) by smtpservice.6wind.com (Postfix) with ESMTP id B30ED131C6; Sun, 19 Jan 2025 18:46:54 +0100 (CET) From: Ariel Otilibili To: dev@dpdk.org Cc: stable@dpdk.org, Thomas Monjalon , David Marchand , Ariel Otilibili , Andrew Rybchenko , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH 2/2] mempool: turn functions into single-exit ones Date: Sun, 19 Jan 2025 18:46:43 +0100 Message-Id: <20250119174643.2162110-3-ariel.otilibili@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250119174643.2162110-1-ariel.otilibili@6wind.com> References: <20250119174643.2162110-1-ariel.otilibili@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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