[PATCH net-next] neighbor: Remove redundant if statement

Subsystems: networking [general], the rest

STALE1724d

2 messages, 2 authors, 2021-11-22 · open the first message on its own page

[PATCH net-next] neighbor: Remove redundant if statement

From: Yajun Deng <hidden>
Date: 2021-11-22 08:49:54

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

Signed-off-by: Yajun Deng <redacted>
---
 include/net/neighbour.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 38a0c1d24570..667129827816 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -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)
-- 
2.32.0

Re: [PATCH net-next] neighbor: Remove redundant if statement

From: Joe Perches <joe@perches.com>
Date: 2021-11-22 09:17:00

On Mon, 2021-11-22 at 16:49 +0800, Yajun Deng wrote:
The if statement already exists in the __neigh_event_send() function,
remove redundant if statement.
[]
quoted hunk
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
[]
quoted hunk
@@ -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);

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help