mac80211: initialize sta pointer to avoid false-positive warning
PATCH v2 1/1 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.
---
In v2:
Changed the second if to "if (sta)" to make it cleaner, as Johannes suggested.
net/mac80211/mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +2 -2
@@ -3032,7 +3032,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,struct ieee80211_local *local = sdata->local;struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;struct ieee80211_bss *bss = (void *)cbss->priv; -struct sta_info *sta; +struct sta_info *sta =NULL ;bool have_sta = false;int err;int ht_cfreq;
@@ -3126,7 +3126,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, local->oper_channel = cbss->channel;ieee80211_hw_config (local,IEEE80211_CONF_CHANGE_CHANNEL ); -if (!have_sta) { +if (sta) {u32 rates =0 , basic_rates =0 ;bool have_higher_than_11mbit;int min_rate =INT_MAX , min_rate_index =-1 ;
Signature · 1 line
1.7.10
Johannes Berg
maintainerQuoted 8 lines · Luciano Coelho
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 functionThis is a false positive because the place where 'sta' is used is inside an if with the same condition of where it is set:
I still think it's a workaround, but what the hell ... applied.
johannes
Quoted 11 lines · Johannes Berg
Quoted 8 lines · Luciano Coelho
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 functionThis is a false positive because the place where 'sta' is used is inside an if with the same condition of where it is set:
I still think it's a workaround, but what the hell ... applied.
Yes, it is a workaround, but a lean one. :) And I think after your suggestion it makes the code slightly more readable.
Thanks for applying!
BTW, when you say you applied, does it mean you have pushed to your tree? We want to remove some of our mac80211 patches from our internal trees and "inherit" them from upstream instead, that's why I'm asking. ;)
--
Luca.
Johannes Berg
maintainerQuoted 4 lines · Luciano Coelho
BTW, when you say you applied, does it mean you have pushed to your tree? We want to remove some of our mac80211 patches from our internal trees and "inherit" them from upstream instead, that's why I'm asking. ;)
It may or may not mean that, I've not quite figured out the entire workflow.
So far, it has basically meant "I'm happy with it and I picked it up into my (local) git tree". I will also push it into one of the mac80211/mac80211-next repositories.
However, I make no guarantees that I don't have to rebase those repositories sometimes, if I were you I wouldn't merge from me right now, at least until I've figured out my workflow completely...
I do plan on sending a pull request to John every week or so though, and when I do I've obviously committed to the code :)
johannes
Quoted 14 lines · Johannes Berg
Quoted 4 lines · Luciano Coelho
BTW, when you say you applied, does it mean you have pushed to your tree? We want to remove some of our mac80211 patches from our internal trees and "inherit" them from upstream instead, that's why I'm asking. ;)
It may or may not mean that, I've not quite figured out the entire workflow.
So far, it has basically meant "I'm happy with it and I picked it up into my (local) git tree". I will also push it into one of the mac80211/mac80211-next repositories.
Quoted 6 lines
However, I make no guarantees that I don't have to rebase those repositories sometimes, if I were you I wouldn't merge from me right now, at least until I've figured out my workflow completely...
I do plan on sending a pull request to John every week or so though, and when I do I've obviously committed to the code :)
Cool, I think I'll wait for your pull then.
--
Luca.