Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: compudj@krystal.dyndns.org (Mathieu Desnoyers)
Subject: [ltt-dev] [PATCH] urcu_ref: do error checking on urcu_ref_put
Date: Thu, 9 Jun 2011 10:14:51 -0400	[thread overview]
Message-ID: <BLU0-SMTP73BCFCEAE9C0F3D7A251B296650@phx.gbl> (raw)
In-Reply-To: <1307627865-31969-2-git-send-email-pbonzini@redhat.com>

* Paolo Bonzini (pbonzini at redhat.com) wrote:
> Underflow is what you really want to trap.  When you reach urcu_ref_get, it
> is already too late.

Merged, thanks!

Mathieu

> 
> Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
> ---
>  urcu/urcu_ref.h |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/urcu/urcu_ref.h b/urcu/urcu_ref.h
> index bce7116..06b81b9 100644
> --- a/urcu/urcu_ref.h
> +++ b/urcu/urcu_ref.h
> @@ -33,14 +33,15 @@ static inline void urcu_ref_init(struct urcu_ref *ref)
>  
>  static inline void urcu_ref_get(struct urcu_ref *ref)
>  {
> -	long res = uatomic_add_return(&ref->refcount, 1);
> -	assert(res != 0);
> +	uatomic_add(&ref->refcount, 1);
>  }
>  
>  static inline void urcu_ref_put(struct urcu_ref *ref,
>  				void (*release)(struct urcu_ref *))
>  {
> -	if (!uatomic_sub_return(&ref->refcount, 1))
> +        long res = uatomic_sub_return(&ref->refcount, 1);
> +        assert (res >= 0);
> +        if (res == 0)
>  		release(ref);
>  }
>  
> -- 
> 1.7.4.4
> 
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




      reply	other threads:[~2011-06-09 14:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-09 13:57 Paolo Bonzini
2011-06-09 14:14 ` Mathieu Desnoyers [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=BLU0-SMTP73BCFCEAE9C0F3D7A251B296650@phx.gbl \
    --to=compudj@krystal.dyndns.org \
    /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