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 E694B46037 for ; Sun, 19 Jan 2025 18:46:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2FA34042F; Sun, 19 Jan 2025 18:46:58 +0100 (CET) Received: from mail-ej1-f100.google.com (mail-ej1-f100.google.com [209.85.218.100]) by mails.dpdk.org (Postfix) with ESMTP id 72686402F1 for ; Sun, 19 Jan 2025 18:46:55 +0100 (CET) Received: by mail-ej1-f100.google.com with SMTP id a640c23a62f3a-aa6b4cc7270so577694866b.0 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=LhI/KYCVLscL4/UY1j1ULhGXmoICsfTmvW3yZM1yaYhg/jpr2vnunsPCPnFLcFt577 o0c/THKonv5198XW7I2ZICHVgMz/+HizGPTyU+8NHWDf+6vHybOSuzmij3GeVtBQbEab omM4g3JWJCtImqCHQKh1sIcscMKeH/AgGSihThX19DtuDY2xgEYd1nfB0yGks6rXXexN M8V1Uo13qnv5TuzIZtDfEKuDG/I/QfxkcZmqEqgIuPF4vsNZe+ZAc4QhIwA1/EZCB7V3 fZaAeA2P/UTpPDv1FfpaSziLBAk2TPCojJxtSpNDNHMLbZeD3Lbn/MQ+G04TueO9+sCh rchA== X-Gm-Message-State: AOJu0YymLPkAVKfLX8aUyCnxFfncEzJDmlZIjrZarpzDKxOVTreVyoIU cf/bDjcfCxXzTXbZSVH31xlYr9rlT+Y4CKJnNb5EUWMrkfpEG96aJDXafjd5c1KzO78dCH6U2X1 UVOfn6R8nXHliN6Lm1ndwfsF3AaQOPczY X-Gm-Gg: ASbGncvM6gZYBGohd9hbwAmV/4jlipu32YVh3kseJleePk/zhvMZWlwSSn+HHhOZmxf ztufadFKOgXC6i6OTboRENsG40gapgW/kuH1VbmeX6/kofvnz6vwfXdpaBVwIfe0dYkV83dzFaG MRKZzK8B408LbhQL4Mr2AzRFHPCQmh8lqj+ZDNOsqQSJIeBb9TIQyvgxVLaiVEJKbrVFcF3ud0Z S7LQc6ZgRFc/jaAW1qEwNdh7AZkb+8rxWB7/Bwf7ESjB2yNeRdxELkWX1HxrZypvDrMTeLiyI8B GkLBapDzYskIZat43EB8Nfz6JmRuZhr+PXwtq/s= 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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