diff mbox series

[net-next] neighbor: Remove redundant if statement

Message ID 20211122084909.18093-1-yajun.deng@linux.dev (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [net-next] neighbor: Remove redundant if statement | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3088 this patch: 3088
netdev/cc_maintainers success CCed 3 of 3 maintainers
netdev/build_clang success Errors and warnings before: 425 this patch: 425
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3221 this patch: 3221
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yajun Deng Nov. 22, 2021, 8:49 a.m. UTC
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(-)

Comments

Joe Perches Nov. 22, 2021, 9:16 a.m. UTC | #1
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);
diff mbox series

Patch

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)