Let's use min()/max() to simplify the code and fix the Coccinelle/coccicheck warning. Signed-off-by: Hongbo Li <lihongbo22@xxxxxxxxxx> --- net/core/pktgen.c | 6 ++---- net/core/sock.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index ea55a758a475..5d4d5ec4a126 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -2793,8 +2793,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(); @@ -2811,8 +2810,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb, if (i == (frags - 1)) skb_frag_fill_page_desc(&skb_shinfo(skb)->frags[i], pkt_dev->page, 0, - (datalen < PAGE_SIZE ? - datalen : PAGE_SIZE)); + min(datalen, PAGE_SIZE)); else skb_frag_fill_page_desc(&skb_shinfo(skb)->frags[i], pkt_dev->page, 0, frag_len); diff --git a/net/core/sock.c b/net/core/sock.c index bbe4c58470c3..c9910f48903f 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3800,7 +3800,7 @@ int sock_prot_inuse_get(struct net *net, struct proto *prot) for_each_possible_cpu(cpu) res += per_cpu_ptr(net->core.prot_inuse, cpu)->val[idx]; - return res >= 0 ? res : 0; + return max(res, 0); } EXPORT_SYMBOL_GPL(sock_prot_inuse_get); -- 2.34.1