* [PATCH v2] myri10ge: remove an unneeded NULL check
@ 2022-03-20 4:44 Xiaomeng Tong
2022-03-22 9:32 ` Paolo Abeni
0 siblings, 1 reply; 2+ messages in thread
From: Xiaomeng Tong @ 2022-03-20 4:44 UTC (permalink / raw)
To: christopher.lee
Cc: davem, kuba, pabeni, netdev, linux-kernel, jakobkoschel, Xiaomeng Tong
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(-)
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;
}
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] myri10ge: remove an unneeded NULL check
2022-03-20 4:44 [PATCH v2] myri10ge: remove an unneeded NULL check Xiaomeng Tong
@ 2022-03-22 9:32 ` Paolo Abeni
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2022-03-22 9:32 UTC (permalink / raw)
To: Xiaomeng Tong, christopher.lee
Cc: davem, kuba, netdev, linux-kernel, jakobkoschel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-22 9:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-20 4:44 [PATCH v2] myri10ge: remove an unneeded NULL check Xiaomeng Tong
2022-03-22 9:32 ` Paolo Abeni
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).