From patchwork Tue Aug 4 07:44:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 503375 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C08ED14028E for ; Tue, 4 Aug 2015 17:46:08 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755358AbbHDHqB (ORCPT ); Tue, 4 Aug 2015 03:46:01 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:47748 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755225AbbHDHpA (ORCPT ); Tue, 4 Aug 2015 03:45:00 -0400 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t747iodv007425 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 Aug 2015 07:44:51 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t747ioQE007623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 4 Aug 2015 07:44:50 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t747iXsJ018055; Tue, 4 Aug 2015 07:44:50 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Aug 2015 00:44:32 -0700 Date: Tue, 4 Aug 2015 10:44:22 +0300 From: Dan Carpenter To: "David S. Miller" Cc: "Eric W. Biederman" , Robert Shearman , Roopa Prabhu , Tom Herbert , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev() Message-ID: <20150804074422.GB10867@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We recently changed this code from returning NULL to returning ERR_PTR. There are some left over NULL assignments which we can remove. We can preserve the error code from ip_route_output() instead of always returning -ENODEV. Also these functions use a mix of gotos and direct returns. There is no cleanup necessary so I changed the gotos to direct returns. Signed-off-by: Dan Carpenter Acked-by: Roopa Prabhu Acked-by: Robert Shearman --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 88cfaa2..d933059 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -337,14 +337,14 @@ static unsigned find_free_label(struct net *net) #if IS_ENABLED(CONFIG_INET) static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) { - struct net_device *dev = NULL; + struct net_device *dev; struct rtable *rt; struct in_addr daddr; memcpy(&daddr, addr, sizeof(struct in_addr)); rt = ip_route_output(net, daddr.s_addr, 0, 0, 0); if (IS_ERR(rt)) - goto errout; + return ERR_CAST(rt); dev = rt->dst.dev; dev_hold(dev); @@ -352,8 +352,6 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) ip_rt_put(rt); return dev; -errout: - return ERR_PTR(-ENODEV); } #else static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) @@ -365,7 +363,7 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) #if IS_ENABLED(CONFIG_IPV6) static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) { - struct net_device *dev = NULL; + struct net_device *dev; struct dst_entry *dst; struct flowi6 fl6; int err; @@ -377,16 +375,13 @@ static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) memcpy(&fl6.daddr, addr, sizeof(struct in6_addr)); err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6); if (err) - goto errout; + return ERR_PTR(err); dev = dst->dev; dev_hold(dev); dst_release(dst); return dev; - -errout: - return ERR_PTR(err); } #else static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr)