All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: eugene.loh@oracle.com
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH] Guard against inserting the same provider twice
Date: Thu, 15 Jan 2026 17:56:07 -0500	[thread overview]
Message-ID: <aWlwh6KNEYXFBtmK@oracle.com> (raw)
In-Reply-To: <20260115222251.7228-1-eugene.loh@oracle.com>

Minor nit below...

On Thu, Jan 15, 2026 at 05:22:51PM -0500, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
> 
> Add a safety net to dt_provider_create(), to check if a specified
> provider has already been inserted.
> 
> This also requires a corresponding change in dt_provider_lookup(), so
> that it will work even if no providers have yet been inserted.
> 
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> ---
>  libdtrace/dt_provider.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libdtrace/dt_provider.c b/libdtrace/dt_provider.c
> index 848fdc132..9d75225fa 100644
> --- a/libdtrace/dt_provider.c
> +++ b/libdtrace/dt_provider.c
> @@ -114,6 +114,8 @@ dt_provider_lookup(dtrace_hdl_t *dtp, const char *name)
>  		return NULL;
>  
>  	strcpy(tmpl.desc.dtvd_name, name);
> +	if (dtp->dt_provs == NULL)
> +		return NULL;

This should be moved as the first conditional in the function, because we
want to return immediately if there is no dtp->dt_provs yet.

>  	return dt_htab_lookup(dtp->dt_provs, &tmpl);
>  }
>  
> @@ -124,6 +126,10 @@ dt_provider_create(dtrace_hdl_t *dtp, const char *name,
>  {
>  	dt_provider_t *pvp;
>  
> +	pvp = dt_provider_lookup(dtp, name);
> +	if (pvp)
> +		return pvp;
> +
>  	if ((pvp = dt_zalloc(dtp, sizeof(dt_provider_t))) == NULL)
>  		goto nomem;
>  
> -- 
> 2.47.3
> 

      reply	other threads:[~2026-01-15 22:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 22:22 [PATCH] Guard against inserting the same provider twice eugene.loh
2026-01-15 22:56 ` Kris Van Hees [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=aWlwh6KNEYXFBtmK@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    --cc=eugene.loh@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.