[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211214114447.439632-1-deng.changcheng@zte.com.cn>
Date: Tue, 14 Dec 2021 11:44:47 +0000
From: cgel.zte@...il.com
To: davem@...emloft.net
Cc: kuba@...nel.org, richardsonnick@...gle.com, edumazet@...gle.com,
zhudi21@...wei.com, songmuchun@...edance.com,
yejune.deng@...il.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Changcheng Deng <deng.changcheng@....com.cn>,
Zeal Robot <zealci@....com.cn>
Subject: [PATCH] pktgen: use min() to make code cleaner
From: Changcheng Deng <deng.changcheng@....com.cn>
Use min() in order to make code cleaner. Issue found by coccinelle.
Reported-by: Zeal Robot <zealci@....com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@....com.cn>
---
net/core/pktgen.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 84b62cd7bc57..7a0b07a22692 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2778,8 +2778,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
}
i = 0;
- frag_len = (datalen/frags) < PAGE_SIZE ?
- (datalen/frags) : PAGE_SIZE;
+ frag_len = min(datalen / frags, PAGE_SIZE);
while (datalen > 0) {
if (unlikely(!pkt_dev->page)) {
int node = numa_node_id();
@@ -2796,7 +2795,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
/*last fragment, fill rest of data*/
if (i == (frags - 1))
skb_frag_size_set(&skb_shinfo(skb)->frags[i],
- (datalen < PAGE_SIZE ? datalen : PAGE_SIZE));
+ min(datalen, PAGE_SIZE));
else
skb_frag_size_set(&skb_shinfo(skb)->frags[i], frag_len);
datalen -= skb_frag_size(&skb_shinfo(skb)->frags[i]);
--
2.25.1
Powered by blists - more mailing lists