[PATCH 2 of 3] inotify: _inotify.c: do not use "goto bail" and XDECREF's when returns can do

Benoit Boissinot benoit.boissinot at ens-lyon.org
Sat Sep 5 08:17:54 CDT 2009


On Mon, Aug 31, 2009 at 05:53:00PM -0500, Matt Mackall wrote:
> On Mon, 2009-08-31 at 10:31 -0700, Bryan O'Sullivan wrote:
> > On Thu, Aug 27, 2009 at 3:01 AM, Nicolas Dumazet <nicdumz at gmail.com>
> > wrote:
> >  inotify: _inotify.c: do not use "goto bail" and XDECREF's when
> >  returns can do
> >  
> >  Using gotos hurt code readability: it's not necessary to put a
> >  goto to a label
> >  containing fail-safe instructions (Py_CLEAR, Py_XDECREF do not
> >  fail if the
> >  the target is NULL) when a simple "return NULL" can do
> >  instead.
> >         
> > 
> > NAK.
> 
> For the record, I agree with Bryan. Mercurial's C coding style is more
> or less the same as the Linux kernel's. And the kernel has evolved this
> particular goto style as a way to robustly deal with unraveling things
> on errors. Other ways exist and might even be more obvious to newcomers,
> but the kernel style is actually better in practice despite violating
> the goto taboo.

In the case where there are no refcounting to be done, I think it
complicates things.

I pushed a patch that removes some gotos, because I thought it was
simpler for this case (I agree with you that doing cleanups after each
failed function-call is ugly and a goto is preferable, but that wasn't
the case here).
http://hg.intevation.org/mercurial/crew-stable/rev/5d6659cfaa06

regards,

Benoit
-- 
:wq


More information about the Mercurial-devel mailing list