From: Emily Peri <eperi1024@gmail.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: gregkh@linuxfoundation.org, outreachy@lists.linux.dev,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: Replace ternary statement with min function
Date: Fri, 28 Oct 2022 10:20:32 -0700 [thread overview]
Message-ID: <Y1wPYCvbV6SMsIEO@marshmallow> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2210270811540.2792@hadrien>
On Thu, Oct 27, 2022 at 08:12:14AM +0200, Julia Lawall wrote:
>
>
> On Wed, 26 Oct 2022, Emily Peri wrote:
>
> > Ternary statements that pick the min of two values can be replaced by
> > the built-in min() function. This improves readability, since its quicker
> > to understand min(x, y) than x < y ? x : y. Issue found by coccicheck.
>
> It looks like a nice change, but I get a compiler error afer the patch,
>
> julia
Okay, I think I know the issue. Another person commented (Dan Carpenter)
that the function needs to be min_t, I'm guessing so the function
returns the value as the correct type. But one thing I'm wondering is,
why I didn't I get a compiler error when I compiled the kernel myself?
Also-- this is just a general question, when we work on drivers I'm
guessing we don't need to include header files from include/linux,
right?
> >
> > Signed-off-by: Emily Peri <eperi1024@gmail.com>
> > ---
> > drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> > index 6aeb169c6ebf..0cf7d9f82b83 100644
> > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> > @@ -1551,7 +1551,7 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
> >
> > wps_ie = rtw_get_wps_ie(buf, ielen, NULL, &wps_ielen);
> > if (wps_ie && wps_ielen > 0) {
> > - padapter->securitypriv.wps_ie_len = wps_ielen < MAX_WPS_IE_LEN ? wps_ielen : MAX_WPS_IE_LEN;
> > + padapter->securitypriv.wps_ie_len = min(wps_ielen, MAX_WPS_IE_LEN);
> > memcpy(padapter->securitypriv.wps_ie, wps_ie, padapter->securitypriv.wps_ie_len);
> > set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS);
> > } else {
> > --
> > 2.34.1
> >
> >
> >
next prev parent reply other threads:[~2022-10-28 17:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 1:26 [PATCH] staging: rtl8723bs: Replace ternary statement with min function Emily Peri
2022-10-27 6:12 ` Julia Lawall
2022-10-28 17:20 ` Emily Peri [this message]
2022-10-27 7:32 ` Dan Carpenter
2022-10-28 17:52 ` Emily Peri
2022-10-28 18:39 ` Julia Lawall
2022-10-29 3:08 ` kernel test robot
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=Y1wPYCvbV6SMsIEO@marshmallow \
--to=eperi1024@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=julia.lawall@inria.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=outreachy@lists.linux.dev \
/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