Skip to content

Commit

Permalink
pktgen: use min() to make code cleaner
Browse files Browse the repository at this point in the history
Use min() in order to make code cleaner. Issue found by coccinelle.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Changcheng Deng <[email protected]>
Reviewed-by: Muchun Song <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Changcheng Deng authored and davem330 committed Dec 14, 2021
1 parent 256f8d7 commit 13510fe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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]);
Expand Down

0 comments on commit 13510fe

Please sign in to comment.