diff options
author | Luciano Coelho <coelho@ti.com> | 2012-06-18 08:52:51 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2012-06-20 04:54:23 -0400 |
commit | 6df653c71e8168e1df01118cc85cd84d0deeb583 (patch) | |
tree | f1a05e10a875eeff275bb7256fa06ced3ced0842 /net/mac80211 | |
parent | 559cef996d2e4c9b652a53bb3a53e5787e247f57 (diff) |
mac80211: initialize sta pointer to avoid false-positive warning
Some compilers (eg. gcc 4.4.1 for ARM) report a false positive warning
in mlme.c:
net/mac80211/mlme.c: In function 'ieee80211_prep_connection':
net/mac80211/mlme.c:3035: warning: 'sta' may be used uninitialized in this function
This is a false positive because the place where 'sta' is used is
inside an if with the same condition of where it is set:
[...]
if (!have_sta) {
sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL);
if (!sta)
return -ENOMEM;
}
[...]
if (!have_sta) {
[...]
sta->sta.supp_rates[cbss->channel->band] = rates;
[...]
For some reason the compiler doesn't understand this and warns.
While this is not a problem in the code itself, we can avoid polluting
the build logs with false positives by setting sta to NULL on
declaration and checking for sta instead of !have_sta in the second if.
Reported-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/mlme.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 0f45d02e0ba7..fa927c6aa14b 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -3012,7 +3012,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, | |||
3012 | struct ieee80211_local *local = sdata->local; | 3012 | struct ieee80211_local *local = sdata->local; |
3013 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 3013 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
3014 | struct ieee80211_bss *bss = (void *)cbss->priv; | 3014 | struct ieee80211_bss *bss = (void *)cbss->priv; |
3015 | struct sta_info *sta; | 3015 | struct sta_info *sta = NULL; |
3016 | bool have_sta = false; | 3016 | bool have_sta = false; |
3017 | int err; | 3017 | int err; |
3018 | int ht_cfreq; | 3018 | int ht_cfreq; |
@@ -3102,7 +3102,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, | |||
3102 | local->oper_channel = cbss->channel; | 3102 | local->oper_channel = cbss->channel; |
3103 | ieee80211_hw_config(local, 0); | 3103 | ieee80211_hw_config(local, 0); |
3104 | 3104 | ||
3105 | if (!have_sta) { | 3105 | if (sta) { |
3106 | u32 rates = 0, basic_rates = 0; | 3106 | u32 rates = 0, basic_rates = 0; |
3107 | bool have_higher_than_11mbit; | 3107 | bool have_higher_than_11mbit; |
3108 | int min_rate = INT_MAX, min_rate_index = -1; | 3108 | int min_rate = INT_MAX, min_rate_index = -1; |