From: "Manu Abraham" <abraham.manu@gmail.com>
To: "Theodore Tso" <tytso@mit.edu>,
"Randy Dunlap" <randy.dunlap@oracle.com>,
"Ahmed S. Darwish" <darwish.07@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: A CodingStyle suggestion
Date: Sun, 4 Feb 2007 16:55:58 +0400 [thread overview]
Message-ID: <1a297b360702040455i7f1c4928waf961cd71e086ca1@mail.gmail.com> (raw)
In-Reply-To: <20070204124819.GC12943@thunk.org>
On 2/4/07, Theodore Tso <tytso@mit.edu> wrote:
> On Sat, Feb 03, 2007 at 01:59:51PM -0800, Randy Dunlap wrote:
> > On Sat, 3 Feb 2007 23:58:48 +0200 Ahmed S. Darwish wrote:
> > >
> > > In CodingStyle Chapter 16 "Function return value and names", why not
> > > adding a comment about the favorable community way of checking the return
> > > value. ie:
> > >
> > > ret = do_method();
> > > if (ret) {
> > > /* deal with error */
> > > }
> > >
> > > and not other ways like:
> > >
> > > if (do_method()) or if ((ret = do_method()) > value) ...
> > >
> >
> > I like it. Please cc: Andrew Morton <akpm@osdl.org> on it.
> > Hopefully he will merge it.
> >
>
> I'm going to have to disagree. Sometimes if the main flow of the code
> is down, it's actually better to do this:
>
> if ((err = do_foo()) < 0)
> return (err);
> if ((err = do_bar(current, filp)) < 0)
> return (err);
> if ((err = do_quux(filp, buffer)) < 0) {
> close(filp);
> return (err);
> }
>
> Than to do something like this:
>
> err = do_foo();
> if (err < 0)
> return (err);
> err = do_bar(current, filp);
> if (err < 0)
> return (err);
> err = do_quux(filp, buffer);
> if (err < 0) {
> close(filp);
> return (err);
> }
>
> The first is more concise, and it draws the reader's eye to what's
> really going on. The cleanup/return error path is less important, and
> and it's pretty clear what's going on just from glancing at it.
Completely agree, as i said in my earlier post.
manu
next prev parent reply other threads:[~2007-02-04 12:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-03 21:58 Ahmed S. Darwish
2007-02-03 21:59 ` Randy Dunlap
2007-02-04 12:48 ` Theodore Tso
2007-02-04 12:55 ` Manu Abraham [this message]
2007-02-04 12:57 ` Robert P. J. Day
2007-02-03 22:56 ` Richard Knutsson
2007-02-04 0:05 ` Ahmed S. Darwish
2007-02-04 0:21 ` Roland Dreier
2007-02-04 0:40 ` Randy Dunlap
2007-02-04 6:35 ` Willy Tarreau
2007-02-04 0:22 ` Tim Schmielau
2007-02-04 0:39 ` Richard Knutsson
2007-02-04 12:10 ` Ahmed S. Darwish
2007-02-04 12:36 ` Manu Abraham
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=1a297b360702040455i7f1c4928waf961cd71e086ca1@mail.gmail.com \
--to=abraham.manu@gmail.com \
--cc=darwish.07@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=randy.dunlap@oracle.com \
--cc=tytso@mit.edu \
/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®