]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
pktgen: use min() to make code cleaner
authorChangcheng Deng <deng.changcheng@zte.com.cn>
Tue, 14 Dec 2021 11:44:47 +0000 (11:44 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Dec 2021 12:49:47 +0000 (12:49 +0000)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/pktgen.c

index 560a5e712dc32fe4aa2cfaa751c3fe1e462c614f..239effb42b617749bee9eb237bb659b8ad0ad956 100644 (file)
@@ -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]);