DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Medvedkin, Vladimir" <vladimir.medvedkin@intel.com>
To: Niall Meade <niall.meade@intel.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Yipeng Wang <yipeng1.wang@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH] hash: separate param checks in hash create func
Date: Wed, 4 Sep 2024 18:28:50 +0100	[thread overview]
Message-ID: <21f0dbf5-16be-47a9-8b98-629d655e0b8c@intel.com> (raw)
In-Reply-To: <20240726145443.1058676-1-niall.meade@intel.com>

Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

On 26/07/2024 15:54, Niall Meade wrote:
> Separated name, entries and key_len parameter checks in
> rte_hash_create().  Also made the error messages more
> informative/verbose to help with debugging. Also added myself to the
> mailing list.
>
> Signed-off-by: Niall Meade <niall.meade@intel.com>
>
> ---
>
> I had name set to NULL in the parameters I was passing to
> rte_hash_create() and the error message I got didn't specify which
> parameter was invalid.
> ---
>   .mailmap                   |  1 +
>   lib/hash/rte_cuckoo_hash.c | 22 ++++++++++++++++++----
>   2 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/.mailmap b/.mailmap
> index 8aef1c59a4..e2a1d55203 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -1054,6 +1054,7 @@ Nelson Escobar <neescoba@cisco.com>
>   Nemanja Marjanovic <nemanja.marjanovic@intel.com>
>   Netanel Belgazal <netanel@amazon.com>
>   Netanel Gonen <netanelg@mellanox.com>
> +Niall Meade <niall.meade@intel.com>
>   Niall Power <niall.power@intel.com>
>   Nicholas Pratte <npratte@iol.unh.edu>
>   Nick Connolly <nick.connolly@arm.com> <nick.connolly@mayadata.io>
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 577b5839d3..97d55ca23b 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -190,11 +190,18 @@ rte_hash_create(const struct rte_hash_parameters *params)
>   
>   	/* 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 has invalid parameters, entries must be "
> +		 "in the range %d to %d inclusive", __func__,
> +		  RTE_HASH_BUCKET_ENTRIES, RTE_HASH_ENTRIES_MAX);
> +		return NULL;
> +	}
> +
> +	if (params->key_len == 0) {
> +		rte_errno = EINVAL;
> +		HASH_LOG(ERR, "%s has invalid parameters, 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)) {

-- 
Regards,
Vladimir


      reply	other threads:[~2024-09-04 17:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26 14:54 Niall Meade
2024-09-04 17:28 ` Medvedkin, Vladimir [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21f0dbf5-16be-47a9-8b98-629d655e0b8c@intel.com \
    --to=vladimir.medvedkin@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=niall.meade@intel.com \
    --cc=sameh.gobriel@intel.com \
    --cc=thomas@monjalon.net \
    --cc=yipeng1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).