[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260131155525.05e1645e@pumpkin>
Date: Sat, 31 Jan 2026 15:55:25 +0000
From: David Laight <david.laight.linux@...il.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: William Hansen-Baird <william.hansen.baird@...il.com>,
gregkh@...uxfoundation.org, straube.linux@...il.com,
linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] staging: rtl8723bs: replace ternary comparison with
min_t()
On Sat, 31 Jan 2026 17:43:10 +0300
Dan Carpenter <dan.carpenter@...aro.org> wrote:
> On Sat, Jan 31, 2026 at 08:31:46AM -0500, William Hansen-Baird wrote:
> > Replace ternary comparison for setting copy_len with the min_t() function
> > from linux/minmax.h.
> > Change is purely cosmetic, however makes the line
> > easier to read without having to reason about logic.
> >
> > ---
> > v2:
> > Drop unrelated style changes and fix style issues by running checkpatch.
> > Keep min_t() to make the signedness of the comparison explicit.
> > (copy_len is an integer, wpa_ie_len is an integer but sizeof yields
> > size_t)
> >
>
> This stuff is supposed to got after the --- cut off line.
>
> > Signed-off-by: William Hansen-Baird <william.hansen.baird@...il.com>
> > ---
> ^^^
>
> > drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > index 8e41eb61448f..d36f6c3bc9b4 100644
> > --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > @@ -4,6 +4,7 @@
> > * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
> > *
> > ******************************************************************************/
> > +#include <linux/minmax.h>
> > #include <drv_types.h>
> > #include <rtw_wifi_regd.h>
> > #include <hal_btcoex.h>
>
> These are supposed to go in alphabetical order, kind of.
I'd always put system/global headers first, but that doesn't seem to be the standard here.
>
> > @@ -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.
David
>
> regards,
> dan carpenter
>
>
Powered by blists - more mailing lists