From: Joe Perches <joe@perches.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: 'Balakumaran Kannan' <kumaran.4353@gmail.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"kuznet@ms2.inr.ac.ru" <kuznet@ms2.inr.ac.ru>,
"jmorris@namei.org" <jmorris@namei.org>,
"yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>,
"kaber@trash.net" <kaber@trash.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH] net : Remove unnecessary assignments
Date: Tue, 18 Mar 2014 10:03:26 -0700 [thread overview]
Message-ID: <1395162206.2812.56.camel@joe-AO722> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D0F6E0472@AcuExch.aculab.com>
On Tue, 2014-03-18 at 16:22 +0000, David Laight wrote:
> From: Behalf Of Balakumaran Kannan
> > Remove unnecessary assignments
> >
> > Signed-off-by: Balakumaran Kannan <kumaran.4353@gmail.com>
> > ---
> > Some unnecessary assignments has been removed from devinet_ioctl function.
> > The 'ret' variable is set in multiple places, but used only based on if
> > conditions. So keeping the assignment inside if will be a better.
> ...
>
> These all seem to be this transform:
> > - ret = -ENODEV;
> > dev = __dev_get_by_name(net, ifr.ifr_name);
> > - if (!dev)
> > + if (!dev) {
> > + ret = -ENODEV;
> > goto done;
> > + }
>
> I bet that if you look at the generated code you'll find
> that the compiler generates the same code for both forms
> and is likely to generate the equivalent of:
> dev = __dev_get_by_name(net, ifr.ifr_name);
> ret = -ENODEV;
> if (!dev)
> goto done;
>
> So this is just a matter of style.
Yabut it's Linus' preferred style.
http://lkml.org/lkml/2008/12/16/383
(but not mine, I prefer what's done by the patch)
next prev parent reply other threads:[~2014-03-18 17:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 16:10 [PATCH] net : Remove unnecessary assignments Balakumaran Kannan
2014-03-18 16:22 ` David Laight
2014-03-18 17:03 ` Joe Perches [this message]
2014-03-19 4:53 ` Balakumaran Kannan
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=1395162206.2812.56.camel@joe-AO722 \
--to=joe@perches.com \
--cc=David.Laight@ACULAB.COM \
--cc=davem@davemloft.net \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kumaran.4353@gmail.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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 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).