From: "KaiLong Wang" <wangkailong@jari.cn>
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()
Date: Sun, 23 Oct 2022 21:07:00 +0800 (GMT+08:00) [thread overview]
Message-ID: <4e5c1182.347.18404f42721.Coremail.wangkailong@jari.cn> (raw)
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 <wangkailong@jari.cn>
---
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;
--
2.25.1
next reply other threads:[~2022-10-23 13:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-23 13:07 KaiLong Wang [this message]
2022-10-23 15:47 ` kernel test robot
2022-10-23 16:07 ` kernel test robot
2022-10-23 23:11 ` kernel test robot
2022-10-24 17:29 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4e5c1182.347.18404f42721.Coremail.wangkailong@jari.cn \
--to=wangkailong@jari.cn \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®