From patchwork Sun Oct 23 13:07:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KaiLong Wang X-Patchwork-Id: 8025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1611088wrr; Sun, 23 Oct 2022 06:13:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74PcI6xNUe0vOr2R77njNrJhEcgKtzOCWYvg4JAfUBYOvKgdf9ymi8mWrXzGKHtYzATLgH X-Received: by 2002:a63:5b5c:0:b0:440:8531:d3f6 with SMTP id l28-20020a635b5c000000b004408531d3f6mr24728734pgm.114.1666530831616; Sun, 23 Oct 2022 06:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666530831; cv=none; d=google.com; s=arc-20160816; b=hJXQFiBgpdkVtyPG5wDn62pMYX6XAXA5M00lDLTtNQQnrxIKXLUj3IKLo2OMPargaJ Rv5BuVMFS00/u1XEPOAYgDjhL4E95bUyjbdcz7WYJZGAXAxwQrFscUsqMN8uoU2ccLtr 6shfDVT1YGVoQDsX8GLJhN8oyySKFy2i+lkG8fh+yK4BzYOsdojMC6hr3el+7zyezc+E UyIriy8DG6l1VMXKYm0afZSnbuAZkuzm7pHxxw5SiluorGCrA83mGuH4/4tuoBfO/PKR ai0mM4qke/cLmIlhvR3QOVrJ1WJHYntiD5ljIJ2opph2XgzH2OgLA5QjPnWSbOhjiKK8 Yufg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:mime-version :content-transfer-encoding:subject:cc:to:from:date; bh=Vcp3LyXzdHH3f5Wn0sRFmIvYD1C6p3Se6ZZuykTkzWA=; b=Ai7pcOk8I5tw+emkUIkkg5wMpOi1sBcQPbTGoSACZzgbIQ/zl+7dllLjmNbDDvcfxo jSSNXU8/I5M7TnZxrpxw/AO0QQcrbxDjEYVoMprWtVDFZG3tPEm+7PM6klU5Qtk03h6z Chk66XiyJq81SW4LXxDSwtUguu91vW47QG6e1Zxd7iz1nwtDuwq0D3x5JqXsBw65WhrY nEaN6sqlbh/9XV6Qi/uhxEOqDUvMkcswP7jLWghcaiLW3G1T4qmsXQmkUOzQWdMYIwBh uCedc501MhUncAAg5HC2jHM9/ROUwlXN/3qSNz7v1DhRS5f5TPmncC7t+vNN2S+DXqo1 qj8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk13-20020a056a02028d00b0046b2bef339csi29751685pgb.257.2022.10.23.06.13.38; Sun, 23 Oct 2022 06:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbiJWNLy (ORCPT + 99 others); Sun, 23 Oct 2022 09:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbiJWNLt (ORCPT ); Sun, 23 Oct 2022 09:11:49 -0400 X-Greylist: delayed 216 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 23 Oct 2022 06:11:32 PDT Received: from jari.cn (unknown [218.92.28.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E4D08625D2; Sun, 23 Oct 2022 06:11:31 -0700 (PDT) Received: by ajax-webmail-localhost.localdomain (Coremail) ; Sun, 23 Oct 2022 21:07:00 +0800 (GMT+08:00) X-Originating-IP: [182.148.15.254] Date: Sun, 23 Oct 2022 21:07:00 +0800 (GMT+08:00) X-CM-HeaderCharset: UTF-8 From: "KaiLong Wang" To: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: replace ternary operator with min() X-Priority: 3 X-Mailer: Coremail Webmail Server Version XT6.0.1 build 20210329(c53f3fee) Copyright (c) 2002-2022 www.mailtech.cn mispb-4e503810-ca60-4ec8-a188-7102c18937cf-zhkzyfz.cn MIME-Version: 1.0 Message-ID: <4e5c1182.347.18404f42721.Coremail.wangkailong@jari.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID: AQAAfwAXIW90PFVjtuVoAA--.1430W X-CM-SenderInfo: 5zdqwypdlo00nj6mt2flof0/1tbiAQAIB2FEYxtOnAACsD X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00,RCVD_IN_PBL,RDNS_NONE, T_SPF_HELO_PERMERROR,T_SPF_PERMERROR,XPRIO autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747484233462817302?= X-GMAIL-MSGID: =?utf-8?q?1747484233462817302?= Fix the following coccicheck warning: net/ipv4/igmp.c:2621: WARNING opportunity for min() net/ipv4/igmp.c:2574: WARNING opportunity for min() net/ipv4/ip_sockglue.c:285: WARNING opportunity for min() Signed-off-by: KaiLong Wang --- net/ipv4/igmp.c | 4 ++-- net/ipv4/ip_sockglue.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 81be3e0f0e70..7939d8febb2b 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -2571,7 +2571,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf, } else { count = psl->sl_count; } - copycount = count < msf->imsf_numsrc ? count : msf->imsf_numsrc; + copycount = min(count, msf->imsf_numsrc); len = flex_array_size(psl, sl_addr, copycount); msf->imsf_numsrc = count; msf_size = IP_MSFILTER_SIZE(copycount); @@ -2618,7 +2618,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf, gsf->gf_fmode = pmc->sfmode; psl = rtnl_dereference(pmc->sflist); count = psl ? psl->sl_count : 0; - copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc; + copycount = min(count, gsf->gf_numsrc); gsf->gf_numsrc = count; for (i = 0; i < copycount; i++) { struct sockaddr_storage ss; diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 6e19cad154f5..19ad37897227 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -282,7 +282,7 @@ int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, /* Our caller is responsible for freeing ipc->opt */ err = ip_options_get(net, &ipc->opt, KERNEL_SOCKPTR(CMSG_DATA(cmsg)), - err < 40 ? err : 40); + min(err, 40)); if (err) return err; break;