diff mbox

rtlwifi: Fix size of wireless mode variable

Message ID 1456419781-14722-1-git-send-email-Larry.Finger@lwfinger.net (mailing list archive)
State Accepted
Delegated to: Kalle Valo
Headers show

Commit Message

Larry Finger Feb. 25, 2016, 5:03 p.m. UTC
Smatch reports the following warning:

  CHECK   drivers/net/wireless/realtek/rtlwifi/rc.c
drivers/net/wireless/realtek/rtlwifi/rc.c:144 _rtl_rc_rate_set_series() warn: impossible condition '(wireless_mode == 256) => (0-255 == 256)'

This warning arises because commit acc6907b87a9 ("rtlwifi: Fix warning
from ieee80211_get_tx_rates() when using 5G") now checks the wireless
mode for WIRELESS_MODE_AC_ONLY (BIT(8)) in _rtl_rc_rate_set_series().
As a result, all quantities used to store the wireless mode must be u16.

This patch also reorders struct rtl_sta_info to save a little space.

Fixes: commit acc6907b87a9 ("rtlwifi: Fix warning from ieee80211_get_tx_rates() when using 5G")
Reported-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/rc.c           | 4 ++--
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c | 2 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h         | 9 ++++-----
 3 files changed, 7 insertions(+), 8 deletions(-)

Comments

Kalle Valo March 7, 2016, 12:38 p.m. UTC | #1
Larry Finger <Larry.Finger@lwfinger.net> writes:

> Smatch reports the following warning:
>
>   CHECK   drivers/net/wireless/realtek/rtlwifi/rc.c
> drivers/net/wireless/realtek/rtlwifi/rc.c:144 _rtl_rc_rate_set_series() warn: impossible condition '(wireless_mode == 256) => (0-255 == 256)'
>
> This warning arises because commit acc6907b87a9 ("rtlwifi: Fix warning
> from ieee80211_get_tx_rates() when using 5G") now checks the wireless
> mode for WIRELESS_MODE_AC_ONLY (BIT(8)) in _rtl_rc_rate_set_series().
> As a result, all quantities used to store the wireless mode must be u16.
>
> This patch also reorders struct rtl_sta_info to save a little space.
>
> Fixes: commit acc6907b87a9 ("rtlwifi: Fix warning from ieee80211_get_tx_rates() when using 5G")
> Reported-by: Dan Williams <dcbw@redhat.com>
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>

I can't find commit acc6907b87a9 from any of my trees. And oddly enough
I can't either any commits with title "rtlwifi: Fix warning from
ieee80211_get_tx_rates() when using 5G". I can fix it before commiting
but what should I use?

Also the fixes line should not have the word "commit".
Larry Finger March 7, 2016, 2:47 p.m. UTC | #2
On 03/07/2016 06:38 AM, Kalle Valo wrote:
> Larry Finger <Larry.Finger@lwfinger.net> writes:
>
>> Smatch reports the following warning:
>>
>>    CHECK   drivers/net/wireless/realtek/rtlwifi/rc.c
>> drivers/net/wireless/realtek/rtlwifi/rc.c:144 _rtl_rc_rate_set_series() warn: impossible condition '(wireless_mode == 256) => (0-255 == 256)'
>>
>> This warning arises because commit acc6907b87a9 ("rtlwifi: Fix warning
>> from ieee80211_get_tx_rates() when using 5G") now checks the wireless
>> mode for WIRELESS_MODE_AC_ONLY (BIT(8)) in _rtl_rc_rate_set_series().
>> As a result, all quantities used to store the wireless mode must be u16.
>>
>> This patch also reorders struct rtl_sta_info to save a little space.
>>
>> Fixes: commit acc6907b87a9 ("rtlwifi: Fix warning from ieee80211_get_tx_rates() when using 5G")
>> Reported-by: Dan Williams <dcbw@redhat.com>
>> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
>
> I can't find commit acc6907b87a9 from any of my trees. And oddly enough
> I can't either any commits with title "rtlwifi: Fix warning from
> ieee80211_get_tx_rates() when using 5G". I can fix it before commiting
> but what should I use?
>
> Also the fixes line should not have the word "commit".

Kalle,

I do not know where I got that commit and title. The correct reference is commit 
d76d65fd2695 ("rtlwifi: fix broken VHT support").

If you would rather not fix this on commit, I can submit a new version.

Thanks,

Larry


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kalle Valo March 8, 2016, 8:50 a.m. UTC | #3
Larry Finger <Larry.Finger@lwfinger.net> writes:

>> I can't find commit acc6907b87a9 from any of my trees. And oddly enough
>> I can't either any commits with title "rtlwifi: Fix warning from
>> ieee80211_get_tx_rates() when using 5G". I can fix it before commiting
>> but what should I use?
>>
>> Also the fixes line should not have the word "commit".
>
> Kalle,
>
> I do not know where I got that commit and title. The correct reference
> is commit d76d65fd2695 ("rtlwifi: fix broken VHT support").
>
> If you would rather not fix this on commit, I can submit a new version.

No need, I can edit the commit log before I commit.
Kalle Valo March 8, 2016, 10:32 a.m. UTC | #4
> Smatch reports the following warning:
> 
>   CHECK   drivers/net/wireless/realtek/rtlwifi/rc.c
> drivers/net/wireless/realtek/rtlwifi/rc.c:144 _rtl_rc_rate_set_series() warn: impossible condition '(wireless_mode == 256) => (0-255 == 256)'
> 
> This warning arises because commit acc6907b87a9 ("rtlwifi: Fix warning
> from ieee80211_get_tx_rates() when using 5G") now checks the wireless
> mode for WIRELESS_MODE_AC_ONLY (BIT(8)) in _rtl_rc_rate_set_series().
> As a result, all quantities used to store the wireless mode must be u16.
> 
> This patch also reorders struct rtl_sta_info to save a little space.
> 
> Fixes: d76d65fd2695 ("rtlwifi: fix broken VHT support")
> Reported-by: Dan Williams <dcbw@redhat.com>
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/realtek/rtlwifi/rc.c b/drivers/net/wireless/realtek/rtlwifi/rc.c
index 28f7010..1aca777 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rc.c
@@ -41,7 +41,7 @@  static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv,
 	struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
 	struct rtl_phy *rtlphy = &(rtlpriv->phy);
 	struct rtl_sta_info *sta_entry = NULL;
-	u8 wireless_mode = 0;
+	u16 wireless_mode = 0;
 
 	/*
 	 *this rate is no use for true rate, firmware
@@ -99,7 +99,7 @@  static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv,
 {
 	struct rtl_mac *mac = rtl_mac(rtlpriv);
 	struct rtl_sta_info *sta_entry = NULL;
-	u8 wireless_mode = 0;
+	u16 wireless_mode = 0;
 	u8 sgi_20 = 0, sgi_40 = 0, sgi_80 = 0;
 
 	if (sta) {
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index 5da9bd0..fe900ba 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -3837,7 +3837,7 @@  void rtl8821ae_update_channel_access_setting(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-	u8 wireless_mode = mac->mode;
+	u16 wireless_mode = mac->mode;
 	u8 sifs_timer, r2t_sifs;
 
 	rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index b07b364..554d814 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -1318,14 +1318,13 @@  struct rtl_tid_data {
 
 struct rtl_sta_info {
 	struct list_head list;
-	u8 ratr_index;
-	u8 wireless_mode;
-	u8 mimo_ps;
-	u8 mac_addr[ETH_ALEN];
 	struct rtl_tid_data tids[MAX_TID_COUNT];
-
 	/* just used for ap adhoc or mesh*/
 	struct rssi_sta rssi_stat;
+	u16 wireless_mode;
+	u8 ratr_index;
+	u8 mimo_ps;
+	u8 mac_addr[ETH_ALEN];
 } __packed;
 
 struct rtl_priv;