AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang@amd.com>
To: "Koenig, Christian" <Christian.Koenig@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Wang, Ken" <Ken.Wang@amd.com>
Subject: Re: [Updated PATCH v2] drm: modify drm_global_item_ref to avoid two times of writing ref->object
Date: Wed, 7 Sep 2016 16:48:35 +0800	[thread overview]
Message-ID: <20160907084835.GA13883@hr-amur2> (raw)
In-Reply-To: <8e0116fa-6f4c-ea4f-5e59-73cb98a543bf@amd.com>

On Wed, Sep 07, 2016 at 04:02:47PM +0800, Koenig, Christian wrote:
> Am 07.09.2016 um 09:54 schrieb Huang Rui:
> > On Wed, Sep 07, 2016 at 09:12:29AM +0200, Christian K?nig wrote:
> >> Am 07.09.2016 um 07:24 schrieb Huang Rui:

snip.

> >>>   	++item->refcount;
> >>> -	ref->object = item->object;
> >>> -	mutex_unlock(&item->mutex);
> >>> -	return 0;
> >>> +	goto out;
> >> A goto in the not error path is a bit unusual. Since out_err is only
> >> used once couldn't you just move the code into the if and then goto
> >> to out as well?
> >>
> >> Alternative you could just duplicate the mutex release in the
> >> non-error path.
> >>
> > Actually, I also have a little concern with "goto" in non-error path. But
> > as Sean's suggestion, use "goto" can avoid a duplicate mutex release, you
> > know.
> 
> I would certainly prefer the duplicate mutex release.
> 
> >
> > @Sean, if you don't have concern with adding a mutex release below, I will
> > update it in V3.
> >
> > ---
> >          ++item->refcount;
> >          mutex_unlock(&item->mutex);
> >          return 0;
> >
> > out_err:
> >          kfree(ref->object);
> >          ref->object = NULL;
> > out:
> 
> BTW: I would name those labels error_free and error_unlock to make clear 
> that they are for error handling and what they are supposed to do.
> 

OK, will rename the label in V3.

Thanks,
Rui
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2016-09-07  8:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-07  5:24 [Updated PATCH v2] drm: modify drm_global_item_ref to avoid two times of writing ref->object Huang Rui
     [not found] ` <1473225871-2847-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2016-09-07  7:12   ` Christian König
     [not found]     ` <88949438-6e9e-502c-a543-9ca374411b1c-5C7GfCeVMHo@public.gmane.org>
2016-09-07  7:54       ` Huang Rui
2016-09-07  8:02         ` Christian König
2016-09-07  8:48           ` Huang Rui [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=20160907084835.GA13883@hr-amur2 \
    --to=ray.huang@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Ken.Wang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.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