public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefani Seibold <stefani@seibold.net>
To: "Bjørn Mork" <bjorn@mork.no>
Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
	oneukum@suse.de, linux-usb@vger.kernel.org
Subject: Re: [PATCH 02/13] code cleanup
Date: Thu, 07 Jun 2012 11:21:46 +0200	[thread overview]
Message-ID: <1339060906.11583.9.camel@wall-e> (raw)
In-Reply-To: <877gvjtrsf.fsf@nemi.mork.no>

Am Donnerstag, den 07.06.2012, 11:06 +0200 schrieb Bjørn Mork:
> stefani@seibold.net writes:
> 
> > @@ -95,15 +93,12 @@ static int skel_open(struct inode *inode, struct file *file)
> >  	if (!interface) {
> >  		pr_err("%s - error, can't find device for minor %d\n",
> >  			__func__, subminor);
> > -		retval = -ENODEV;
> > -		goto exit;
> > +		return -ENODEV;
> >  	}
> 
> 
> This may save you a line, but that line was there for a reason...
> 
> Using a common exit path for errors makes it easier to keep unlocking,
> deallocation and other cleanups correct.  Although you *can* do that
> change now, you introduce future bugs here.  Someone adding a lock
> before this will now have to go through all the error paths to ensure
> that they unlock before exiting.
> 
> See "Chapter 7: Centralized exiting of functions" in
> Documentation/CodingStyle.
> 

If it is necessary... I get alway ten different complains from six
developers. Developer A says do it in this way, developer B do it in the
other way.

> Focus on creating a *good* example.  Compacting the code is not
> necessarily improving the code...
> 

Compacting improves since it will make the code more readable.

> 
> 
> >  	/* verify that we actually have some data to write */
> > -	if (count == 0)
> > -		goto exit;
> > +	if (!count)
> > +		return 0;
> 
> zero-testing is discussed over and over again, and is a matter of
> taste. But I fail to see how changing it can be part of a cleanup.  It
> just changes the flavour to suit another taste.  What's the reason for
> doing that?
> 

Consistency - there are a lot places in the driver skeleton handling
this in the same way.




  reply	other threads:[~2012-06-07  9:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-07  8:20 [PATCH] fix usb skeleton driver stefani
2012-06-07  8:20 ` [PATCH 01/13] fix wrong label in skel_open stefani
2012-06-13  1:03   ` Greg KH
2012-06-07  8:20 ` [PATCH 02/13] code cleanup stefani
2012-06-07  9:06   ` Bjørn Mork
2012-06-07  9:21     ` Stefani Seibold [this message]
2012-06-07 10:49       ` Bjørn Mork
2012-06-13  1:03         ` Greg KH
2012-06-13  1:02   ` Greg KH
2012-06-13 18:00     ` Stefani Seibold
2012-06-07  8:20 ` [PATCH 03/13] remove dead code stefani
2012-06-07 15:04   ` Oliver Neukum
2012-06-07 19:40     ` Stefani Seibold
2012-06-07  8:20 ` [PATCH 04/13] remove unneeded forward declaration stefani
2012-06-07  8:20 ` [PATCH 05/13] remove pr_err() noise in skel_open stefani
2012-06-07  8:20 ` [PATCH 06/13] Handle a non blocking read without blocking stefani
2012-06-07  8:20 ` [PATCH 07/13] fix flush function stefani
2012-06-07  8:20 ` [PATCH 08/13] add fsync function stefani
2012-06-07  8:20 ` [PATCH 09/13] remove unneeded lock in skel_open stefani
2012-06-07  8:20 ` [PATCH 10/13] fix race in skel_write stefani
2012-06-07  8:20 ` [PATCH 11/13] fix kref usage in skel_open stefani
2012-06-07  8:20 ` [PATCH 12/13] Introduce single user mode stefani
2012-06-13  1:05   ` Greg KH
2012-06-07  8:20 ` [PATCH 13/13] Bump version number and add aditional author stefani
2012-06-07  9:09   ` Bjørn Mork
2012-06-13  1:00     ` Greg KH

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=1339060906.11583.9.camel@wall-e \
    --to=stefani@seibold.net \
    --cc=bjorn@mork.no \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.de \
    /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