public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Pkshih <pkshih@realtek.com>
Cc: Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Colin Ian King <colin.king@canonical.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Joe Perches <joe@perches.com>, Kaixu Xia <kaixuxia@tencent.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hardening@vger.kernel.org"
	<linux-hardening@vger.kernel.org>
Subject: Re: [PATCH] rtlwifi: rtl8192de: Style clean-ups
Date: Wed, 25 Aug 2021 19:32:55 -0700	[thread overview]
Message-ID: <202108251932.C28B9C4B4@keescook> (raw)
In-Reply-To: <3e0b0efc0c0142bbb79cb11f927967bb@realtek.com>

On Thu, Aug 26, 2021 at 12:58:13AM +0000, Pkshih wrote:
> 
> > -----Original Message-----
> > From: Kees Cook [mailto:keescook@chromium.org]
> > Sent: Thursday, August 26, 2021 2:34 AM
> > To: Pkshih
> > Cc: Kees Cook; Kalle Valo; David S. Miller; Jakub Kicinski; Larry Finger; Colin Ian King;
> > linux-wireless@vger.kernel.org; netdev@vger.kernel.org; Joe Perches; Kaixu Xia;
> > linux-kernel@vger.kernel.org; linux-hardening@vger.kernel.org
> > Subject: [PATCH] rtlwifi: rtl8192de: Style clean-ups
> > 
> > Clean up some style issues:
> > - Use ARRAY_SIZE() even though it's a u8 array.
> > - Remove redundant CHANNEL_MAX_NUMBER_2G define.
> > Additionally fix some dead code WARNs.
> > 
> > Cc: Ping-Ke Shih <pkshih@realtek.com>
> > Cc: Kalle Valo <kvalo@codeaurora.org>
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Cc: Jakub Kicinski <kuba@kernel.org>
> > Cc: Larry Finger <Larry.Finger@lwfinger.net>
> > Cc: Colin Ian King <colin.king@canonical.com>
> > Cc: linux-wireless@vger.kernel.org
> > Cc: netdev@vger.kernel.org
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > ---
> >  drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c | 8 +++-----
> >  drivers/net/wireless/realtek/rtlwifi/wifi.h          | 1 -
> >  2 files changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
> > b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
> > index b32fa7a75f17..9807c9e91998 100644
> > --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
> > +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
> > @@ -899,7 +899,7 @@ static u8 _rtl92c_phy_get_rightchnlplace(u8 chnl)
> >  	u8 place = chnl;
> > 
> >  	if (chnl > 14) {
> > -		for (place = 14; place < sizeof(channel5g); place++) {
> > +		for (place = 14; place < ARRAY_SIZE(channel5g); place++) {
> 
> There are still many places we can use ARRAY_SIZE() instead of sizeof().
> Could you fix them within this file, even this driver?
> Otherwise, this patch looks good to me.

Sure! I found a couple more and have sent a v2.

-Kees

> 
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>
> 
> >  			if (channel5g[place] == chnl) {
> >  				place++;
> >  				break;
> > @@ -2861,16 +2861,14 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw)
> >  	case BAND_ON_5G:
> >  		/* Get first channel error when change between
> >  		 * 5G and 2.4G band. */
> > -		if (channel <= 14)
> > +		if (WARN_ONCE(channel <= 14, "rtl8192de: 5G but channel<=14\n"))
> >  			return 0;
> > -		WARN_ONCE((channel <= 14), "rtl8192de: 5G but channel<=14\n");
> >  		break;
> >  	case BAND_ON_2_4G:
> >  		/* Get first channel error when change between
> >  		 * 5G and 2.4G band. */
> > -		if (channel > 14)
> > +		if (WARN_ONCE(channel > 14, "rtl8192de: 2G but channel>14\n"))
> >  			return 0;
> > -		WARN_ONCE((channel > 14), "rtl8192de: 2G but channel>14\n");
> >  		break;
> >  	default:
> >  		WARN_ONCE(true, "rtl8192de: Invalid WirelessMode(%#x)!!\n",
> > diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h
> > b/drivers/net/wireless/realtek/rtlwifi/wifi.h
> > index aa07856411b1..31f9e9e5c680 100644
> > --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
> > +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
> > @@ -108,7 +108,6 @@
> >  #define	CHANNEL_GROUP_IDX_5GM		6
> >  #define	CHANNEL_GROUP_IDX_5GH		9
> >  #define	CHANNEL_GROUP_MAX_5G		9
> > -#define CHANNEL_MAX_NUMBER_2G		14
> >  #define AVG_THERMAL_NUM			8
> >  #define AVG_THERMAL_NUM_88E		4
> >  #define AVG_THERMAL_NUM_8723BE		4
> > --
> > 2.30.2
> 

-- 
Kees Cook

      reply	other threads:[~2021-08-26  2:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 18:33 [PATCH] rtlwifi: rtl8192de: Style clean-ups Kees Cook
2021-08-26  0:58 ` Pkshih
2021-08-26  2:32   ` Kees Cook [this message]

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=202108251932.C28B9C4B4@keescook \
    --to=keescook@chromium.org \
    --cc=Larry.Finger@lwfinger.net \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=joe@perches.com \
    --cc=kaixuxia@tencent.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pkshih@realtek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox