[nbd168-wireless:mt76 52/56] drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:2105:3: warning: variable 'nrates' is uninitialized when used here

From: kernel test robot
Date: Fri Aug 27 2021 - 03:10:11 EST


tree: https://github.com/nbd168/wireless mt76
head: 9c19de7d8b1d007dc5f2c396c26ef6a45d4097fc
commit: 48469214f50cda8765f3800360997f06886eb331 [52/56] mt76: mt7915: rework .set_bitrate_mask() to support more options
config: i386-randconfig-a005-20210827 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1076082a0d97bd5c16a25ee7cf3dbb6ee4b5a9fe)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/nbd168/wireless/commit/48469214f50cda8765f3800360997f06886eb331
git remote add nbd168-wireless https://github.com/nbd168/wireless
git fetch --no-tags nbd168-wireless mt76
git checkout 48469214f50cda8765f3800360997f06886eb331
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:2105:3: warning: variable 'nrates' is uninitialized when used here [-Wuninitialized]
__sta_phy_bitrate_mask_check(he_mcs, he_gi, 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:2100:4: note: expanded from macro '__sta_phy_bitrate_mask_check'
nrates += hweight16(mask->control[band]._mcs[i]); \
^~~~~~
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:2089:17: note: initialize the variable 'nrates' to silence this warning
int ret, nrates;
^
= 0
1 warning generated.


vim +/nrates +2105 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c

2078
2079 static int
2080 mt7915_mcu_add_rate_ctrl_fixed(struct mt7915_dev *dev,
2081 struct ieee80211_vif *vif,
2082 struct ieee80211_sta *sta)
2083 {
2084 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
2085 struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef;
2086 struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask;
2087 enum nl80211_band band = chandef->chan->band;
2088 struct sta_phy phy = {};
2089 int ret, nrates;
2090
2091 #define __sta_phy_bitrate_mask_check(_mcs, _gi, _he) \
2092 do { \
2093 u8 i, gi = mask->control[band]._gi; \
2094 gi = (_he) ? gi : gi == NL80211_TXRATE_FORCE_SGI; \
2095 for (i = 0; i <= sta->bandwidth; i++) { \
2096 phy.sgi |= gi << (i << (_he)); \
2097 phy.he_ltf |= mask->control[band].he_ltf << (i << (_he));\
2098 } \
2099 for (i = 0; i < ARRAY_SIZE(mask->control[band]._mcs); i++) \
2100 nrates += hweight16(mask->control[band]._mcs[i]); \
2101 phy.mcs = ffs(mask->control[band]._mcs[0]) - 1; \
2102 } while (0)
2103
2104 if (sta->he_cap.has_he) {
> 2105 __sta_phy_bitrate_mask_check(he_mcs, he_gi, 1);
2106 } else if (sta->vht_cap.vht_supported) {
2107 __sta_phy_bitrate_mask_check(vht_mcs, gi, 0);
2108 } else if (sta->ht_cap.ht_supported) {
2109 __sta_phy_bitrate_mask_check(ht_mcs, gi, 0);
2110 } else {
2111 nrates = hweight32(mask->control[band].legacy);
2112 phy.mcs = ffs(mask->control[band].legacy) - 1;
2113 }
2114 #undef __sta_phy_bitrate_mask_check
2115
2116 /* fall back to auto rate control */
2117 if (mask->control[band].gi == NL80211_TXRATE_DEFAULT_GI &&
2118 mask->control[band].he_gi == GENMASK(7, 0) &&
2119 mask->control[band].he_ltf == GENMASK(7, 0) &&
2120 nrates != 1)
2121 return 0;
2122
2123 /* fixed single rate */
2124 if (nrates == 1) {
2125 ret = mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, &phy,
2126 RATE_PARAM_FIXED_MCS);
2127 if (ret)
2128 return ret;
2129 }
2130
2131 /* fixed GI */
2132 if (mask->control[band].gi != NL80211_TXRATE_DEFAULT_GI ||
2133 mask->control[band].he_gi != GENMASK(7, 0)) {
2134 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
2135 u32 addr;
2136
2137 /* firmware updates only TXCMD but doesn't take WTBL into
2138 * account, so driver should update here to reflect the
2139 * actual txrate hardware sends out.
2140 */
2141 addr = mt7915_mac_wtbl_lmac_addr(dev, msta->wcid.idx, 7);
2142 if (sta->he_cap.has_he)
2143 mt76_rmw_field(dev, addr, GENMASK(31, 24), phy.sgi);
2144 else
2145 mt76_rmw_field(dev, addr, GENMASK(15, 12), phy.sgi);
2146
2147 ret = mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, &phy,
2148 RATE_PARAM_FIXED_GI);
2149 if (ret)
2150 return ret;
2151 }
2152
2153 /* fixed HE_LTF */
2154 if (mask->control[band].he_ltf != GENMASK(7, 0)) {
2155 ret = mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, &phy,
2156 RATE_PARAM_FIXED_HE_LTF);
2157 if (ret)
2158 return ret;
2159 }
2160
2161 return 0;
2162 }
2163

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip