Skip to contentSkip to conversation

mac80211: avoid "uninitialised variable" warning

PATCH In review Antonio Quartulli 2 participants 2 messages May 20, 2014 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: avoid "uninitialised variable" warning

gcc is not able to correlate chan_pwr and have_chan_pwr in ieee80211_handle_pwr_constr(), therefore it throws a warning about chan_pwr being potentially used uninitialised even if this is not true.

However, initialise chan_pwr to 0 to silent the warning.

---
 net/mac80211/mlme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mlme.c +1 -1
index 7f073ef..43a2a7c 100644
@@ -1146,7 +1146,7 @@ static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
 {
 	struct ieee80211_country_ie_triplet *triplet;
 	int chan = ieee80211_frequency_to_channel(channel->center_freq);
-	int i, chan_pwr, chan_increment, new_ap_level;
+	int i, chan_pwr = 0, chan_increment, new_ap_level;
 	bool have_chan_pwr = false;
 
 	/* Invalid IE */
Signature · 1 line
1.8.5.5
maintainer
#1 lore raw
Quoted 6 lines · Antonio Quartulli

gcc is not able to correlate chan_pwr and have_chan_pwr in ieee80211_handle_pwr_constr(), therefore it throws a warning about chan_pwr being potentially used uninitialised even if this is not true.

However, initialise chan_pwr to 0 to silent the warning.

I don't see any warnings (even with -Wmaybe-uninitialized added manually) and don't like gratuitous initializations, so I'll drop this.

johannes