* [PATCH] pktgen: use min() to make code cleaner
@ 2021-12-14 11:44 cgel.zte
2021-12-14 12:07 ` Muchun Song
0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2021-12-14 11:44 UTC (permalink / raw)
To: davem
Cc: kuba, richardsonnick, edumazet, zhudi21, songmuchun, yejune.deng,
netdev, linux-kernel, Changcheng Deng, Zeal Robot
From: Changcheng Deng <deng.changcheng@zte.com.cn>
Use min() in order to make code cleaner. Issue found by coccinelle.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pktgen: use min() to make code cleaner
2021-12-14 11:44 [PATCH] pktgen: use min() to make code cleaner cgel.zte
@ 2021-12-14 12:07 ` Muchun Song
0 siblings, 0 replies; 2+ messages in thread
From: Muchun Song @ 2021-12-14 12:07 UTC (permalink / raw)
To: cgel.zte
Cc: David Miller, Jakub Kicinski, richardsonnick, Eric Dumazet,
zhudi21, yejune.deng, Networking, LKML, Changcheng Deng,
Zeal Robot
On Tue, Dec 14, 2021 at 7:44 PM <cgel.zte@gmail.com> wrote:
>
> From: Changcheng Deng <deng.changcheng@zte.com.cn>
>
> Use min() in order to make code cleaner. Issue found by coccinelle.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-14 12:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 11:44 [PATCH] pktgen: use min() to make code cleaner cgel.zte
2021-12-14 12:07 ` Muchun Song
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).