From: William Hansen-Baird <william.hansen.baird@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: David Laight <david.laight.linux@gmail.com>,
gregkh@linuxfoundation.org, straube.linux@gmail.com,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: rtl8723bs: replace ternary comparison with min_t()
Date: Sat, 31 Jan 2026 16:43:54 -0500 [thread overview]
Message-ID: <aX53mt0cFlcz_2VB@william-fedora> (raw)
In-Reply-To: <aX49e37jGXj674bq@stanley.mountain>
On Sat, Jan 31, 2026 at 08:35:55PM +0300, Dan Carpenter wrote:
> On Sat, Jan 31, 2026 at 03:55:25PM +0000, David Laight wrote:
> > > > @@ -1024,7 +1025,7 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter,
> > > > pstat->flags |= WLAN_STA_WPS;
> > > > copy_len = 0;
> > > > } else {
> > > > - copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)):(wpa_ie_len+2);
> > > > + copy_len = min_t(int, sizeof(pstat->wpa_ie), wpa_ie_len + 2);
> > >
> > > Use umin(). "int" is wrong because we don't want negative values
> > > stored in copy_len.
> >
> > And the correct way to fix min() bleating is to change the type of the variables.
> > Using min_t() ought to be frowned up and only used as a last resort.
> >
> > In this case I think all the variables declared with wpa_ie_len can/should be
> > unsigned int.
> >
>
> That also works.
>
Hi Dan and David,
Thanks for your help. After reviewing the code, I do see a few checks
ensuring wpa_ie_len is never negative.
Therefore umin() is safe in this case, and for v3 I'll update the patch accordingly.
Would you prefer I leave it at that, or is a broader change to
make wpa_ie_len unsigned worth doing in a separate patch?
Thanks,
William
next prev parent reply other threads:[~2026-01-31 21:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 13:31 [PATCH v2] staging: rtl8723bs: replace ternary comparison with min_t() William Hansen-Baird
2026-01-31 14:43 ` Dan Carpenter
2026-01-31 15:55 ` David Laight
2026-01-31 17:35 ` Dan Carpenter
2026-01-31 21:43 ` William Hansen-Baird [this message]
2026-01-31 22:58 ` David Laight
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=aX53mt0cFlcz_2VB@william-fedora \
--to=william.hansen.baird@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=david.laight.linux@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=straube.linux@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.