netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] neighbor: Remove redundant if statement
@ 2021-11-22  8:49 Yajun Deng
  2021-11-22  9:16 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Yajun Deng @ 2021-11-22  8:49 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, Yajun Deng

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

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] neighbor: Remove redundant if statement
  2021-11-22  8:49 [PATCH net-next] neighbor: Remove redundant if statement Yajun Deng
@ 2021-11-22  9:16 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2021-11-22  9:16 UTC (permalink / raw)
  To: Yajun Deng, davem, kuba; +Cc: netdev, linux-kernel

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.
[]
> diff --git 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);
>  }

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);



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-22  9:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22  8:49 [PATCH net-next] neighbor: Remove redundant if statement Yajun Deng
2021-11-22  9:16 ` Joe Perches

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).