diff mbox series

[v2] myri10ge: remove an unneeded NULL check

Message ID 20220320044457.13734-1-xiam0nd.tong@gmail.com (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series [v2] myri10ge: remove an unneeded NULL check | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
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: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Xiaomeng Tong March 20, 2022, 4:44 a.m. UTC
The define of skb_list_walk_safe(first, skb, next_skb) is:
  for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb);  \
     (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL)

Thus, if the 'segs' passed as 'first' into the skb_list_walk_safe is NULL,
the loop will exit immediately. In other words, it can be sure the 'segs'
is non-NULL when we run inside the loop. So just remove the unnecessary
NULL check. Also remove the unneeded assignmnets.

Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
---
changes since v1:
 - remove the unneeded assignmnets.

v1: https://lore.kernel.org/lkml/20220319052350.26535-1-xiam0nd.tong@gmail.com/
---
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Paolo Abeni March 22, 2022, 9:32 a.m. UTC | #1
Hello,

On Sun, 2022-03-20 at 12:44 +0800, Xiaomeng Tong wrote:
> The define of skb_list_walk_safe(first, skb, next_skb) is:
>   for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb);  \
>      (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL)
> 
> Thus, if the 'segs' passed as 'first' into the skb_list_walk_safe is NULL,
> the loop will exit immediately. In other words, it can be sure the 'segs'
> is non-NULL when we run inside the loop. So just remove the unnecessary
> NULL check. Also remove the unneeded assignmnets.
> 
> Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>

This is pure net-next material, and we are now into the merge window -
only fixes allowed. Please repost in 2w, thanks!

Paolo
diff mbox series

Patch

diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index 50ac3ee2577a..071657e3dba8 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -2903,12 +2903,8 @@  static netdev_tx_t myri10ge_sw_tso(struct sk_buff *skb,
 		status = myri10ge_xmit(curr, dev);
 		if (status != 0) {
 			dev_kfree_skb_any(curr);
-			if (segs != NULL) {
-				curr = segs;
-				segs = next;
-				curr->next = NULL;
-				dev_kfree_skb_any(segs);
-			}
+			segs->next = NULL;
+			dev_kfree_skb_any(next);
 			goto drop;
 		}
 	}