Commit 13510fef authored by Changcheng Deng's avatar Changcheng Deng Committed by David S. Miller

pktgen: use min() to make code cleaner

Use min() in order to make code cleaner. Issue found by coccinelle.
Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
Signed-off-by: default avatarChangcheng Deng <deng.changcheng@zte.com.cn>
Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 256f8d72
...@@ -2778,8 +2778,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb, ...@@ -2778,8 +2778,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
} }
i = 0; i = 0;
frag_len = (datalen/frags) < PAGE_SIZE ? frag_len = min(datalen / frags, PAGE_SIZE);
(datalen/frags) : PAGE_SIZE;
while (datalen > 0) { while (datalen > 0) {
if (unlikely(!pkt_dev->page)) { if (unlikely(!pkt_dev->page)) {
int node = numa_node_id(); int node = numa_node_id();
...@@ -2796,7 +2795,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb, ...@@ -2796,7 +2795,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
/*last fragment, fill rest of data*/ /*last fragment, fill rest of data*/
if (i == (frags - 1)) if (i == (frags - 1))
skb_frag_size_set(&skb_shinfo(skb)->frags[i], skb_frag_size_set(&skb_shinfo(skb)->frags[i],
(datalen < PAGE_SIZE ? datalen : PAGE_SIZE)); min(datalen, PAGE_SIZE));
else else
skb_frag_size_set(&skb_shinfo(skb)->frags[i], frag_len); skb_frag_size_set(&skb_shinfo(skb)->frags[i], frag_len);
datalen -= skb_frag_size(&skb_shinfo(skb)->frags[i]); datalen -= skb_frag_size(&skb_shinfo(skb)->frags[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment