Skip to contentSkip to conversation

neighbor: Remove redundant if statement

PATCH In review Yajun Deng 2 participants 2 messages Nov 22, 2021

Subsystems (2)
lore
Share & tools
lore

Yajun Deng

author
#0 lore raw

PATCH 1/1 neighbor: Remove redundant if statement

The if statement already exists in the __neigh_event_send() function, remove redundant if statement.

---
 include/net/neighbour.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/net/neighbour.h +1 -3
index 38a0c1d24570..667129827816 100644
@@ -452,9 +452,7 @@ static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
 	
 	if (READ_ONCE(neigh->used) != now)
 		WRITE_ONCE(neigh->used, now);
-	if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE)))
-		return __neigh_event_send(neigh, skb);
-	return 0;
+	return __neigh_event_send(neigh, skb);
 }
 
 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
Signature · 1 line
2.32.0
#1 lore raw
Quoted 2 lines · Yajun Deng

The if statement already exists in the __neigh_event_send() function, remove redundant if statement.

[]

include/net/neighbour.h

Quoted 1 line
include/net/neighbour.h +0 -0

[]

include/net/neighbour.h static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) · line 456

Quoted 9 lines
include/net/neighbour.h +1 -3
@@ -452,9 +452,7 @@ static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
 
 	if (READ_ONCE(neigh->used) != now)
 		WRITE_ONCE(neigh->used, now);
-	if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE)))
-		return __neigh_event_send(neigh, skb);
-	return 0;
+	return __neigh_event_send(neigh, skb);
 }

Perhaps this is an optimization to avoid the lock/unlock in __neigh_event_send? If so a comment could be useful.

And also perhaps this code would be clearer with the test reversed:

	if (neigh->nud_state & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE))
		return 0;

	return __neigh_event_send(neigh, skb);