mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Opensource [Anthony Olech]" <anthony.olech.opensource@diasemi.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: CodingStyle
Date: Thu, 18 Apr 2013 06:41:45 -0700	[thread overview]
Message-ID: <20130418134145.GB2767@roeck-us.net> (raw)
In-Reply-To: <24DF37198A1E704D9811D8F72B87EB514191EABF@NB-EX-MBX02.diasemi.com>

On Thu, Apr 18, 2013 at 10:48:06AM +0000, Opensource [Anthony Olech] wrote:
> > -----Original Message-----
> > From: Guenter Roeck [mailto:linux@roeck-us.net]
> > Sent: 18 April 2013 05:14
> > To: Opensource [Anthony Olech]
> > Cc: Jean Delvare; Mark Brown; Randy Dunlap; lm-sensors@lm-sensors.org;
> > LKML; David Dajun Chen
> > Subject: Re: [NEW DRIVER V5 6/7] drivers/hwmon: DA9058 HWMON driver
> > 
> [...]
> > > +	if (cell == NULL) {
> > > +		ret = -ENODEV;
> > > +		goto exit;
> > 
> > Just return -ENODEV is good enough here. See CodingStyle, chapter 7.
> > 
> [...]
> > > +exit:
> > > +	return ret;
> > > +}
> [...]
> 
> Hi Guenter,
> 
> I have read CodingStyle, chapter 7 and it seems to encourage a single exit point from functions.
> 
Yes, unless you can return directly. There is even an example.
It actually says "... and some common work such as cleanup has to be done".

> During development there was some logging done at the (single) exit point but that has been stripped out for submission.
> Whilst I can duplicate the logging and do an immediate 'return' at all those points, I am hesitant to do so when chapter 7 of the CodingStyle appears to say to use a single exit point. In addition I had thought that a single exit point from functions was a good thing.
> 
Not if you add a goto to a return statement. That defeats the purpose
of easy readability.

Guenter

  reply	other threads:[~2013-04-18 13:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-18 10:48 CodingStyle Opensource [Anthony Olech]
2013-04-18 13:41 ` Guenter Roeck [this message]
2013-04-18 16:06   ` CodingStyle Opensource [Anthony Olech]
     [not found] <90e6ba4fc2a4f7dd3c04971cb0fa@google.com>
2010-12-11  7:18 ` CodingStyle HarryWei
  -- strict thread matches above, loose matches on Subject: below --
2006-08-31 12:37 sound/pci/hda/intel_hda: small cleanups Pavel Machek
2006-08-31 13:01 ` Takashi Iwai
2006-08-31 18:04   ` CodingStyle (was: Re: sound/pci/hda/intel_hda: small cleanups) Randy.Dunlap
2006-09-02 23:15     ` Pavel Machek
2006-09-03  4:30       ` Randy.Dunlap
2006-09-05  8:08         ` Pavel Machek
2006-09-05 16:40           ` CodingStyle Stefan Richter

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=20130418134145.GB2767@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=anthony.olech.opensource@diasemi.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®