All of lore.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: "Voelker, Bernhard" <bernhard.voelker@siemens-enterprise.com>
Cc: Dave Reisner <d@falconindy.com>,
	"util-linux@vger.kernel.org" <util-linux@vger.kernel.org>,
	Dave Reisner <dreisner@archlinux.org>
Subject: Re: [PATCH 1/2] mountpoint: refactor exit path
Date: Tue, 11 Oct 2011 09:44:27 +0200	[thread overview]
Message-ID: <20111011074427.GH11730@nb.net.home> (raw)
In-Reply-To: <7856072A9D04C24B82DFE2B1112FE38A0D83B8E942@MCHP058A.global-ad.net>

On Tue, Oct 11, 2011 at 09:07:15AM +0200, Voelker, Bernhard wrote:
> > +finish:
> > +	return rc;
> 
> IMHO 'goto' is ugly and should only be used in more difficult
> cases. In this case - if you really liked to avoid several
> free(spec) statements - it could be easily done with a few
> else statements.


kernel Documentation/CodingStyle:

  Albeit deprecated by some people, the equivalent of the goto statement is
  used frequently by compilers in form of the unconditional jump instruction.

  The goto statement comes in handy when a function exits from multiple
  locations and some common work such as cleanup has to be done.

  The rationale is:

  - unconditional statements are easier to understand and follow
  - nesting is reduced
  - errors by not updating individual exit points when making
    modifications are prevented
  - saves the compiler work to optimize redundant code away ;)


BTW, now you know why I don't like free-before-exit in simple utils
like mountpoint(1). It makes code less readable and needlessly
complicated.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2011-10-11  7:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 23:14 [PATCH 1/2] mountpoint: refactor exit path Dave Reisner
2011-10-10 23:14 ` [PATCH 2/2] mountpoint: support symbolic and relative paths Dave Reisner
2011-10-11  9:34   ` Karel Zak
2011-10-11  7:07 ` [PATCH 1/2] mountpoint: refactor exit path Voelker, Bernhard
2011-10-11  7:44   ` Karel Zak [this message]
2011-10-11  7:55     ` Voelker, Bernhard
2011-10-11  8:14       ` Karel Zak
2011-10-11  9:06 ` Karel Zak
2011-10-11  9:31   ` Karel Zak
  -- strict thread matches above, loose matches on Subject: below --
2011-10-09 15:12 Dave Reisner
2011-10-10 19:45 ` Dave Reisner
2011-10-10 23:05   ` Karel Zak

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=20111011074427.GH11730@nb.net.home \
    --to=kzak@redhat.com \
    --cc=bernhard.voelker@siemens-enterprise.com \
    --cc=d@falconindy.com \
    --cc=dreisner@archlinux.org \
    --cc=util-linux@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 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.