* [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev()
@ 2015-08-04 7:44 Dan Carpenter
2015-08-04 13:40 ` roopa
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-08-04 7:44 UTC (permalink / raw)
To: David S. Miller
Cc: Eric W. Biederman, Robert Shearman, Roopa Prabhu, Tom Herbert,
netdev, kernel-janitors
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 <dan.carpenter@oracle.com>
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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev()
2015-08-04 7:44 [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev() Dan Carpenter
@ 2015-08-04 13:40 ` roopa
2015-08-04 13:53 ` Robert Shearman
2015-08-07 4:57 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: roopa @ 2015-08-04 13:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: David S. Miller, Eric W. Biederman, Robert Shearman, Tom Herbert,
netdev, kernel-janitors
On 8/4/15, 12:44 AM, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev()
2015-08-04 7:44 [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev() Dan Carpenter
2015-08-04 13:40 ` roopa
@ 2015-08-04 13:53 ` Robert Shearman
2015-08-07 4:57 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Robert Shearman @ 2015-08-04 13:53 UTC (permalink / raw)
To: Dan Carpenter, David S. Miller
Cc: Eric W. Biederman, Roopa Prabhu, Tom Herbert, netdev,
kernel-janitors
On 04/08/15 08:44, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
Acked-by: Robert Shearman <rshearma@brocade.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev()
2015-08-04 7:44 [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev() Dan Carpenter
2015-08-04 13:40 ` roopa
2015-08-04 13:53 ` Robert Shearman
@ 2015-08-07 4:57 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-08-07 4:57 UTC (permalink / raw)
To: dan.carpenter; +Cc: ebiederm, rshearma, roopa, tom, netdev, kernel-janitors
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Tue, 4 Aug 2015 10:44:22 +0300
> 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 <dan.carpenter@oracle.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-07 4:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-04 7:44 [patch] mpls: small cleanup in inet/inet6_fib_lookup_dev() Dan Carpenter
2015-08-04 13:40 ` roopa
2015-08-04 13:53 ` Robert Shearman
2015-08-07 4:57 ` David Miller
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).