Re: [PATCH 1/2] mountpoint: refactor exit path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux