Skip to contentSkip to conversation

net: merge redundancy judgement

PATCH David Miller 1 participant 2 messages Apr 29, 2015 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

David Miller

author maintainer
#1 lore raw
In reply to a message not in the archive

From: Martin Zhang <[email protected]>
Date: Wed, 29 Apr 2015 11:35:59 +0800

Quoted 13 lines

'if' and 'elseif' do the same operation,
so merge then into a case.

---
 net/ipv4/route.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
net/ipv4/route.c +0 -0
index ad50643..9b5468c 100644

net/ipv4/route.c static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst) · line 806

Quoted 10 lines
net/ipv4/route.c +2 -5
@@ -802,11 +802,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *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) {
+		if (dst->obsolete > 0 || (rt->rt_flags & RTCF_REDIRECTED)
+		 || rt->dst.expires) {

Never begin lines with conditional operators. Rather, end lines with conditional operators, as it was in the original code.

author maintainer
#3 lore raw
In reply to a message not in the archive

From: Martin Zhang <[email protected]>
Date: Wed, 29 Apr 2015 17:09:24 +0800

Quoted 13 lines

'if' and 'elseif' do the same operation,
so merge then into a case.

---
 net/ipv4/route.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
net/ipv4/route.c +0 -0
index a78540f..2a50411 100644

net/ipv4/route.c static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst) · line 805

Quoted 10 lines
net/ipv4/route.c +2 -5
@@ -801,11 +801,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *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) {
+		if (dst->obsolete > 0 || (rt->rt_flags & RTCF_REDIRECTED) ||
+			rt->dst.expires) {

This is not indented properly.

When an if() condition spans multiple lines, the second and subsequent lines must start precisely at the first column after the openning parenthesis of the first line. You must use the appropriate number of TAB and SPACE characters necessary to do so.

You would do well to simply follow the coding style that existed in the lines you are editing, because you are only running into trouble because you are styling things differently from what is happening there already.