From: Dan Carpenter <dan.carpenter@oracle.com>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
Tomasz Figa <t.figa@samsung.com>, Felipe Balbi <balbi@ti.com>,
Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: Re: [patch] drivers: phy: tweaks to phy_create()
Date: Wed, 06 Nov 2013 09:30:50 +0000 [thread overview]
Message-ID: <20131106093050.GG20521@mwanda> (raw)
In-Reply-To: <5279F9AE.303@ti.com>
On Wed, Nov 06, 2013 at 01:41:26PM +0530, Kishon Vijay Abraham I wrote:
> >The rest of this patch is just cleanup like returning directly instead
> >of having do-nothing gotos. Using descriptive labels instead of
>
> Grouping the err returns in the end looked a bit cleaner to me. It's
> just a matter of preference I guess.
Say if you are reading the code and it says:
goto err0;
What you think is, "Huh, that's a crap name for a label. I wonder what
it does?" So you have interrupt what you are doing and scroll down and
then you see that it doesn't do anything. Not a single thing. It just
returns. Then you have to scroll back and try remember where you were.
But if you use a clear label like:
ret = -ENOMEM;
goto return_ret;
Then I don't have to scroll down to find out what it is.
But it's even more clear to just say:
return -ENOMEM;
The original code was not just messy, it was also buggy. If you do the
error handling in the right way by unwinding in the correct order and
thinking about label names then your code will be less buggy.
regards,
dan carpenter
next prev parent reply other threads:[~2013-11-06 9:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-06 7:54 [patch] drivers: phy: tweaks to phy_create() Dan Carpenter
2013-11-06 8:23 ` Kishon Vijay Abraham I
2013-11-06 9:30 ` Dan Carpenter [this message]
2013-11-11 14:49 ` Kishon Vijay Abraham I
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=20131106093050.GG20521@mwanda \
--to=dan.carpenter@oracle.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=t.figa@samsung.com \
/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;
as well as URLs for NNTP newsgroup(s).