netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	devel@openvz.org, "Denis V. Lunev" <den@openvz.org>
Subject: [PATCH 2/6] [IPV4]: Small style cleanup of the error path in rtm_to_ifaddr.
Date: Thu, 31 Jan 2008 15:00:46 +0300	[thread overview]
Message-ID: <1201780850-22216-2-git-send-email-den@openvz.org> (raw)
In-Reply-To: <47A1B835.7050600@sw.ru>

Remove error code assignment inside brackets on failure. The code looks better
if the error is assigned before condition check. Also, the compiler treats this
better.

Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 net/ipv4/devinet.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 21f71bf..9da4c68 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -492,39 +492,34 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
 	struct ifaddrmsg *ifm;
 	struct net_device *dev;
 	struct in_device *in_dev;
-	int err = -EINVAL;
+	int err;
 
 	err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv4_policy);
 	if (err < 0)
 		goto errout;
 
 	ifm = nlmsg_data(nlh);
-	if (ifm->ifa_prefixlen > 32 || tb[IFA_LOCAL] == NULL) {
-		err = -EINVAL;
+	err = -EINVAL;
+	if (ifm->ifa_prefixlen > 32 || tb[IFA_LOCAL] == NULL)
 		goto errout;
-	}
 
 	dev = __dev_get_by_index(&init_net, ifm->ifa_index);
-	if (dev == NULL) {
-		err = -ENODEV;
+	err = -ENODEV;
+	if (dev == NULL)
 		goto errout;
-	}
 
 	in_dev = __in_dev_get_rtnl(dev);
-	if (in_dev == NULL) {
-		err = -ENOBUFS;
+	err = -ENOBUFS;
+	if (in_dev == NULL)
 		goto errout;
-	}
 
 	ifa = inet_alloc_ifa();
-	if (ifa == NULL) {
+	if (ifa == NULL)
 		/*
 		 * A potential indev allocation can be left alive, it stays
 		 * assigned to its device and is destroy with it.
 		 */
-		err = -ENOBUFS;
 		goto errout;
-	}
 
 	ipv4_devconf_setall(in_dev);
 	in_dev_hold(in_dev);
-- 
1.5.3.rc5


  parent reply	other threads:[~2008-01-31 12:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31 11:59 [PATCH 0/6] preparations to enable netdevice notifiers inside a namespace (resend) Denis V. Lunev
2008-01-31 12:00 ` [PATCH 1/6] [IPV4]: Fix memory leak on error path during FIB initialization Denis V. Lunev
2008-01-31 13:14   ` David Miller
2008-01-31 12:00 ` Denis V. Lunev [this message]
2008-01-31 12:00 ` [PATCH 3/6] [NETNS]: Process interface address manipulation routines in the namespace Denis V. Lunev
2008-01-31 12:00 ` [PATCH 4/6] [IPV4]: fib_sync_down rework Denis V. Lunev
2008-01-31 12:00 ` [PATCH 5/6] [NETNS]: Add a namespace mark to fib_info Denis V. Lunev
2008-01-31 12:00 ` [PATCH 6/6] [NETNS]: Lookup in FIB semantic hashes taking into account the namespace Denis V. Lunev
2008-01-31 14:58 ` [PATCH 0/6] preparations to enable netdevice notifiers inside a namespace (resend) Daniel Lezcano
     [not found]   ` <47A1E21C.40909-GANU6spQydw@public.gmane.org>
2008-01-31 16:47     ` Benjamin Thery
2008-01-31 17:46       ` Daniel Lezcano
2008-02-01  2:50 ` David Miller

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=1201780850-22216-2-git-send-email-den@openvz.org \
    --to=den@openvz.org \
    --cc=davem@davemloft.net \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.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).