2024-05-04 11:19:31

by Ping-Ke Shih

[permalink] [raw]
Subject: [PATCH] wifi: rtlwifi: 8192d: initialize rate_mask in rtl92de_update_hal_rate_mask()

le32p_replace_bits() only updates partial bits of rate_mask, and gcc warns
below. Set initial value to avoid warnings, and prevent random value of
missed bits (bit 6 of rate_mask.macid_and_short_gi).

In file included from ./include/linux/fortify-string.h:5,
from ./include/linux/string.h:369,
from ./include/linux/bitmap.h:13,
from ./include/linux/cpumask.h:13,
from ./include/linux/sched.h:16,
from drivers/net/wireless/realtek/rtlwifi/rtl8192d/../wifi.h:9,
from drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c:4:
In function 'le32p_replace_bits',
inlined from 'rtl92de_update_hal_rate_mask.isra' at drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c:986:2:
./include/linux/bitfield.h:189:15: warning: 'rate_mask' is used uninitialized [-Wuninitialized]
189 | *p = (*p & ~to(field)) | type##_encode_bits(val, field); \
| ^~
./include/linux/bitfield.h:196:9: note: in expansion of macro '____MAKE_OP'
196 | ____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \
| ^~~~~~~~~~~
./include/linux/bitfield.h:201:1: note: in expansion of macro '__MAKE_OP'
201 | __MAKE_OP(32)
| ^~~~~~~~~
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c: In function 'rtl92de_update_hal_rate_mask.isra':
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c:863:37: note: 'rate_mask' declared here
863 | struct rtl92d_rate_mask_h2c rate_mask;
| ^~~~~~~~~

Fixes: 014bba73b525 ("wifi: rtlwifi: Adjust rtl8192d-common for USB")
Cc: Bitterblue Smith <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
---
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c
index 920bfb4eaaef..6570d5e168e9 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c
@@ -857,10 +857,10 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
{
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
+ struct rtl92d_rate_mask_h2c rate_mask = {};
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_phy *rtlphy = &rtlpriv->phy;
struct rtl_sta_info *sta_entry = NULL;
- struct rtl92d_rate_mask_h2c rate_mask;
enum wireless_mode wirelessmode;
bool shortgi = false;
u8 curshortgi_40mhz;
--
2.25.1



2024-05-04 12:11:20

by Ping-Ke Shih

[permalink] [raw]
Subject: Re: [PATCH] wifi: rtlwifi: 8192d: initialize rate_mask in rtl92de_update_hal_rate_mask()

Ping-Ke Shih <[email protected]> wrote:

> le32p_replace_bits() only updates partial bits of rate_mask, and gcc warns
> below. Set initial value to avoid warnings, and prevent random value of
> missed bits (bit 6 of rate_mask.macid_and_short_gi).
>
> In file included from ./include/linux/fortify-string.h:5,
> from ./include/linux/string.h:369,
> from ./include/linux/bitmap.h:13,
> from ./include/linux/cpumask.h:13,
> from ./include/linux/sched.h:16,
> from drivers/net/wireless/realtek/rtlwifi/rtl8192d/../wifi.h:9,
> from drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c:4:
> In function 'le32p_replace_bits',
> inlined from 'rtl92de_update_hal_rate_mask.isra' at drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c:986:2:
> ./include/linux/bitfield.h:189:15: warning: 'rate_mask' is used uninitialized [-Wuninitialized]
> 189 | *p = (*p & ~to(field)) | type##_encode_bits(val, field); \
> | ^~
> ./include/linux/bitfield.h:196:9: note: in expansion of macro '____MAKE_OP'
> 196 | ____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \
> | ^~~~~~~~~~~
> ./include/linux/bitfield.h:201:1: note: in expansion of macro '__MAKE_OP'
> 201 | __MAKE_OP(32)
> | ^~~~~~~~~
> drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c: In function 'rtl92de_update_hal_rate_mask.isra':
> drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c:863:37: note: 'rate_mask' declared here
> 863 | struct rtl92d_rate_mask_h2c rate_mask;
> | ^~~~~~~~~
>
> Fixes: 014bba73b525 ("wifi: rtlwifi: Adjust rtl8192d-common for USB")
> Cc: Bitterblue Smith <[email protected]>
> Signed-off-by: Ping-Ke Shih <[email protected]>

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

82b85a836a59 wifi: rtlwifi: 8192d: initialize rate_mask in rtl92de_update_hal_rate_mask()

---

This is to quickly fix GCC warning [1] to prevent blocking pull-request.

[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#mdcc6bc74e1600b4c6f4ac3b97a5324ef07816db4

---
https://github.com/pkshih/rtw.git