net: ipv4: route.c: Remove unnecessary if()
Subsystems (3)
PATCH 2/2 net: ipv4: route.c: Remove unnecessary if()
negative_advice handler is only called when dst is non-NULL hence the 'if (rt)' check can be removed. 'if' and 'else if' can be merged together. And use container_of() instead of (struct rtable *).
Signed-off-by Yejune Deng <[email protected]>
--- net/ipv4/route.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
net/ipv4/route.c +6 -10
@@ -814,19 +814,15 @@ static void ip_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bufstatic struct dst_entry *ipv4_negative_advice (struct dst_entry *dst) { -struct rtable *rt = (struct rtable *)dst; + struct rtable *rt = container_of(dst, struct rtable, dst);struct dst_entry *ret = dst; -if (rt) { -if (dst->obsolete >0 ) { -ip_rt_put (rt); - ret =NULL ; - }else if ((rt->rt_flags &RTCF_REDIRECTED ) || - rt->dst.expires) { -ip_rt_put (rt); - ret =NULL ; - } +if (dst->obsolete >0 || rt->dst.expires || + (rt->rt_flags &RTCF_REDIRECTED )) { +ip_rt_put (rt); + ret =NULL ; } +return ret; }
Signature · 1 line
2.29.0
Quoted 9 lines · Yejune Deng
negative_advicehandler is only called when dst is non-NULL hence the 'if (rt)' check can be removed. 'if' and 'else if' can be merged together. And usecontainer_of()instead of (struct rtable *).Signed-off-by Yejune Deng <[email protected]>--- net/ipv4/route.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
Reviewed-by David Ahern <[email protected]>