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 B26A845B5F; Thu, 17 Oct 2024 17:11:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 67D164025F; Thu, 17 Oct 2024 17:11:46 +0200 (CEST) Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) by mails.dpdk.org (Postfix) with ESMTP id DA3844021E for ; Thu, 17 Oct 2024 17:11:44 +0200 (CEST) Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 7767E138070A; Thu, 17 Oct 2024 11:11:44 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 17 Oct 2024 11:11:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1729177904; x= 1729264304; bh=P5NyDfXEKd9g6cXmi0l6V77mFqVY5tB4VVoJb/DQ0ig=; b=f 5UWKMQHsMAKdeLbMxa98YBRrD56PXEs1AsZ09nz5SuOmIC/hGdOHvnkOEx3y4WDw /47rBVH0bUbx+JfAXtL7+bW2rLaym3T0KYkCtWi3gQqEiMAWSYNBuWgq766jcSJY MLTGH0kHSHdIQ58eyW/9z7JkXHI3t1cyx4NUaIe8ljyszzhMgjoiEv9dZHu6ZwZw zxpVIKt2xDPSgll/zJaqA11PjZQM76WN39N7OedNp5tBbNfqnAWFNfu/wOO0tU4U GMpaEbA2u/FP6F4nRASVJx7KLXEJIASsprezSpdXfN0b10eC90MCBirux2FHEsCf MmfX/TsWhRjOZKC2sZTcA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1729177904; x= 1729264304; bh=P5NyDfXEKd9g6cXmi0l6V77mFqVY5tB4VVoJb/DQ0ig=; b=T Extk4Fxoy+wq3rGp8KvKgj3O0HidykIxj4qukELf7HPeQD6BEAqk9ivhK4zW0FYg Qa5f7ow1gvAn3+Vh0PYS989JPrexr+ESNU2rTZzh8ioDqZabxQXUitaaAxRaJlDf 98wjjWSprLfIB+5mKE2Sig5RVtxxStGsQGGenuiy9JWdVKpVY9zTsE3ooAml0TJa utS6344hAi7RXgCwqnPbpKxkf1bEeMyMKhT3UwuB/jqhPLiOWV5oUbc5QuBHuHfS 4s2vUC5w+yDSLJ9rSOA7TstBnxokqjP/zQ6aOjbmBaNRdQtpagosYnmT7KPedNqK 31soMVIKpIHUzHf0iGpyQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdehuddgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttden ucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrg hlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpedvjefhudeghedvtdeijeeigeetuedu gfejueekieeltdfhteevkeehhfeilefhtdenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtpdhn sggprhgtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeguvghvse guphgukhdrohhrghdprhgtphhtthhopehnihgrlhhlrdhmvggruggvsehinhhtvghlrdgt ohhmpdhrtghpthhtohepshhtvghphhgvnhesnhgvthifohhrkhhplhhumhgsvghrrdhorh hgpdhrtghpthhtohephihiphgvnhhguddrfigrnhhgsehinhhtvghlrdgtohhmpdhrtghp thhtohepshgrmhgvhhdrghhosghrihgvlhesihhnthgvlhdrtghomhdprhgtphhtthhope gsrhhutggvrdhrihgthhgrrhgushhonhesihhnthgvlhdrtghomhdprhgtphhtthhopehv lhgrughimhhirhdrmhgvughvvggukhhinhesihhnthgvlhdrtghomh X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 17 Oct 2024 11:11:42 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Niall Meade , Stephen Hemminger , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v4] hash: separate creation parameters checks Date: Thu, 17 Oct 2024 17:10:19 +0200 Message-ID: <20241017151131.2499153-1-thomas@monjalon.net> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240726145443.1058676-1-niall.meade@intel.com> References: <20240726145443.1058676-1-niall.meade@intel.com> MIME-Version: 1.0 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 From: Niall Meade Separate name, entries and key_len parameter checks in rte_hash_create(). Also make the error messages more informative/verbose to help with debugging. Signed-off-by: Niall Meade Acked-by: Stephen Hemminger --- v4: formatting details sent for triggering a new CI run --- lib/hash/rte_cuckoo_hash.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 577b5839d3..9575e8aa0c 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -184,17 +184,24 @@ rte_hash_create(const struct rte_hash_parameters *params) hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list); if (params == NULL) { + rte_errno = EINVAL; HASH_LOG(ERR, "%s has no parameters", __func__); return NULL; } /* Check for valid parameters */ if ((params->entries > RTE_HASH_ENTRIES_MAX) || - (params->entries < RTE_HASH_BUCKET_ENTRIES) || - (params->name == NULL) || - (params->key_len == 0)) { + (params->entries < RTE_HASH_BUCKET_ENTRIES)) { rte_errno = EINVAL; - HASH_LOG(ERR, "%s has invalid parameters", __func__); + HASH_LOG(ERR, "%s() entries (%u) must be in range [%d, %d] inclusive", + __func__, params->entries, RTE_HASH_BUCKET_ENTRIES, + RTE_HASH_ENTRIES_MAX); + return NULL; + } + + if (params->key_len == 0) { + rte_errno = EINVAL; + HASH_LOG(ERR, "%s() key_len must be greater than 0", __func__); return NULL; } @@ -204,6 +211,13 @@ rte_hash_create(const struct rte_hash_parameters *params) return NULL; } + if (params->name == NULL) { + rte_errno = EINVAL; + HASH_LOG(ERR, "%s() has invalid parameters, name can't be NULL", + __func__); + return NULL; + } + /* Validate correct usage of extra options */ if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) && (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) { -- 2.46.0