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 D6B3E460C5; Mon, 20 Jan 2025 13:22:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C980A40E54; Mon, 20 Jan 2025 13:22:23 +0100 (CET) Received: from mail-lf1-f97.google.com (mail-lf1-f97.google.com [209.85.167.97]) by mails.dpdk.org (Postfix) with ESMTP id 635A440E36 for ; Mon, 20 Jan 2025 13:22:22 +0100 (CET) Received: by mail-lf1-f97.google.com with SMTP id 2adb3069b0e04-53e389d8dc7so4443929e87.0 for ; Mon, 20 Jan 2025 04:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1737375742; x=1737980542; 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=13N10RDYO8V5/P7fWWf1cwtghuSGAEEa145FMHTIz3o=; b=GkjIvcvwaW/cUz54dOaQ4zjdlyEs5oPrhornwzGxp2lYhaK/Cue+Rx/qfB3DlYa8Pk NynLBpVWNET4ab8DoxEo0FtILzQhOGb9lEZOkuCfeO6KvEIb6oJelkBHI2OQnoQBAJO0 iXfJfBXR5O6QKhttgyoqB0g1Bsym2Bdlszcaa8QfVjVi3ESgG2eFm7AxT2Ld8BxHIAlR ywQImXDTMUlkW3mbXhdpuUbkzZELIfGdskG/O9xoxx7t/dDNsH0kdrW7uEbMrUi6CV6D m4gB/0nI0ZEreT+UqFxGU/FuBDD9aFHOBN+a4iKAc+l0Ql6ajw3zZkj83Y1QB0s8VIlL NAzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737375742; x=1737980542; 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=13N10RDYO8V5/P7fWWf1cwtghuSGAEEa145FMHTIz3o=; b=FAx/lw9N20mqGURcSYOg6R8VDF9ymNSMbTv/Tafz1b9vskoQ510u2EqO5er+OrmHEN BF7qAnTa66KIF847HDv0u/E0ZmjRJGTsziRre9zrCcTT+o9CNFrAXIi8SRkYC6ug3lwS gjfvp8VoRGrtWnxIvgdHorCsYsWTj9rM7x+x3ZowoHMmIdmiC+wlfUWrm1twlVbl5iVc E8mfeWgCWp74Hj0Ql3jaHEFYPmOOXfFAM6436D5uhIeSZBFC3aMTXTEraDNuD2OKMT9P KZqyrFmGKVLLmvRgN7HWjMCfm7F3GdwUtcLFGTt8bGD4wYWb0KpANHofpI4US6ALRsmX ZDbw== X-Gm-Message-State: AOJu0YwkE4JsUYTHEa9J5Ex8s7OeAf5EhJU3yma6Vj3K1TdV514uBziJ PQ2coR4oHuzP2+tGkPtAkLMTwidCfexdPkkRgl3nwSv37+Ca91VwM4Ojm7LmbEOJTe5CFQr5Wdh 9mcM1X6Qw32/EZJ4ydIklamFeID8q2hH2Z5BpNk7Y X-Gm-Gg: ASbGncu6DXlA3aC+0QHoBX9DQ7QSLvupViD0k6w4mQdDez9/L2yEuh0O8ppwYf6F5XO aF25AVyVCN14GuKlxqWGW5EITsHEtTU0CJCTT3+UL9hkKZsnSUa6uEUaD+1sD/1wWOtHQqEkF08 ZnktZhzTcFpyJe++STLSPWhOQxZ42Yidcnr8GeQHGlkyyhenGgqjZrNZKwRueQhB/C9L+EsmONq a2wr3GRnKR0NcqO8W+B90l7J3pgz9MOSmGYs37l8qdigBB5Whbcl2d2qLDRtmslLvksExC5VB88 DsiTzR7dHIDN6Nh/eXU6K9JUsB6jLlCuA3pcjxI= X-Google-Smtp-Source: AGHT+IG9KEJ+sVO8TsSGe7+T35E8TTZZ8MDTzmt/CugxkkiLPlD52gZkFlIumVEqtPfZqXISv1kP/Ckvgc5n X-Received: by 2002:ac2:42c1:0:b0:542:7196:d1ed with SMTP id 2adb3069b0e04-5439c2807d8mr3320850e87.53.1737375741789; Mon, 20 Jan 2025 04:22:21 -0800 (PST) Received: from smtpservice.6wind.com ([185.13.181.2]) by smtp-relay.gmail.com with ESMTP id 2adb3069b0e04-5439af5fbbdsm240637e87.92.2025.01.20.04.22.21; Mon, 20 Jan 2025 04:22:21 -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 66E2C138E8; Mon, 20 Jan 2025 13:22:21 +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?= , Konstantin Ananyev Subject: [PATCH v2 2/2] mempool: make rte_mempool_create_empty a single-exit Date: Mon, 20 Jan 2025 13:21:56 +0100 Message-Id: <20250120122156.2480524-3-ariel.otilibili@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250120122156.2480524-1-ariel.otilibili@6wind.com> References: <20250119174643.2162110-1-ariel.otilibili@6wind.com> <20250120122156.2480524-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 For properly setting rte_errno, and exiting rte_mempool_create_empty() from a single place. Bugzilla ID: 1559 Signed-off-by: Ariel Otilibili --- lib/mempool/rte_mempool.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index 1e4f24783c0b..3f9a4a1771d3 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -831,20 +831,20 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, /* asked for zero items */ if (n == 0) { rte_errno = EINVAL; - return NULL; + goto exit; } /* asked cache too big */ if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE || CALC_CACHE_FLUSHTHRESH(cache_size) > n) { rte_errno = EINVAL; - return NULL; + goto exit; } /* enforce only user flags are passed by the application */ if ((flags & ~RTE_MEMPOOL_VALID_USER_FLAGS) != 0) { rte_errno = EINVAL; - return NULL; + goto exit; } /* @@ -860,7 +860,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, /* calculate mempool object sizes. */ if (!rte_mempool_calc_obj_size(elt_size, flags, &objsz)) { rte_errno = EINVAL; - return NULL; + goto exit; } rte_mcfg_mempool_write_lock(); @@ -877,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { RTE_MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!"); - goto exit_unlock; + goto unlock; } mempool_size = RTE_MEMPOOL_HEADER_SIZE(mp, cache_size); @@ -887,12 +887,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, ret = snprintf(mz_name, sizeof(mz_name), RTE_MEMPOOL_MZ_FORMAT, name); if (ret < 0 || ret >= (int)sizeof(mz_name)) { rte_errno = ENAMETOOLONG; - goto exit_unlock; + goto unlock; } mz = rte_memzone_reserve(mz_name, mempool_size, socket_id, mz_flags); if (mz == NULL) - goto exit_unlock; + goto unlock; /* init the mempool structure */ mp = mz->addr; @@ -900,7 +900,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, ret = strlcpy(mp->name, name, sizeof(mp->name)); if (ret < 0 || ret >= (int)sizeof(mp->name)) { rte_errno = ENAMETOOLONG; - goto exit_unlock; + goto unlock; } mp->mz = mz; mp->size = n; @@ -930,7 +930,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, if (ret) { rte_errno = -ret; - goto exit_unlock; + goto unlock; } /* @@ -956,13 +956,16 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, rte_mempool_trace_create_empty(name, n, elt_size, cache_size, private_data_size, flags, mp); - return mp; + goto exit; -exit_unlock: +unlock: rte_mcfg_mempool_write_unlock(); rte_free(te); rte_mempool_free(mp); - return NULL; + mp = NULL; + +exit: + return mp; } /* create the mempool */ -- 2.30.2 <