2011-11-11 18:45:12

by John W. Linville

[permalink] [raw]
Subject: [PATCH] mac80211: fix warning in ieee80211_probe_client

CC [M] net/mac80211/cfg.o
net/mac80211/cfg.c: In function ‘ieee80211_probe_client’:
net/mac80211/cfg.c:2567:7: warning: ‘qos’ may be used uninitialized in this function

Signed-off-by: John W. Linville <[email protected]>
---
net/mac80211/cfg.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index c2416fb..1d82d2b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2564,7 +2564,7 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
struct sk_buff *skb;
int size = sizeof(*nullfunc);
__le16 fc;
- bool qos;
+ bool qos = NULL;
struct ieee80211_tx_info *info;
struct sta_info *sta;

--
1.7.4.4



2011-11-11 19:24:44

by John W. Linville

[permalink] [raw]
Subject: [PATCH v2] mac80211: fix warning in ieee80211_probe_client

CC [M] net/mac80211/cfg.o
net/mac80211/cfg.c: In function ‘ieee80211_probe_client’:
net/mac80211/cfg.c:2567:7: warning: ‘qos’ may be used uninitialized in this function

Signed-off-by: John W. Linville <[email protected]>
---
v2 -- use "false" instead of "NULL" for initializing bool -- duh!

net/mac80211/cfg.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index c2416fb..a097d60 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2564,7 +2564,7 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
struct sk_buff *skb;
int size = sizeof(*nullfunc);
__le16 fc;
- bool qos;
+ bool qos = false;
struct ieee80211_tx_info *info;
struct sta_info *sta;

--
1.7.4.4


2011-11-11 19:22:34

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix warning in ieee80211_probe_client

On Fri, 2011-11-11 at 13:32 -0500, John W. Linville wrote:
> CC [M] net/mac80211/cfg.o
> net/mac80211/cfg.c: In function ‘ieee80211_probe_client’:
> net/mac80211/cfg.c:2567:7: warning: ‘qos’ may be used uninitialized in this function

Hm, you need a better compiler ;-) How about below instead (keeping the
subject)? I kinda don't like just initialising the variable "randomly".

johannes


From: Johannes Berg <[email protected]>

The warning is spurious -- if !sta we always exit without using the
unassigned qos variable, and if we do find the sta we assign it.

Signed-off-by: Johannes Berg <[email protected]>
---

--- wireless-testing.orig/net/mac80211/cfg.c 2011-11-10 09:29:29.000000000 +0100
+++ wireless-testing/net/mac80211/cfg.c 2011-11-11 20:21:08.000000000 +0100
@@ -2530,12 +2530,13 @@ static int ieee80211_probe_client(struct

rcu_read_lock();
sta = sta_info_get(sdata, peer);
- if (sta)
+ if (sta) {
qos = test_sta_flag(sta, WLAN_STA_WME);
- rcu_read_unlock();
-
- if (!sta)
+ rcu_read_unlock();
+ } else {
+ rcu_read_unlock();
return -ENOLINK;
+ }

if (qos) {
fc = cpu_to_le16(IEEE80211_FTYPE_DATA |



2011-11-11 19:30:11

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix warning in ieee80211_probe_client

On Fri, Nov 11, 2011 at 08:22:30PM +0100, Johannes Berg wrote:
> On Fri, 2011-11-11 at 13:32 -0500, John W. Linville wrote:
> > CC [M] net/mac80211/cfg.o
> > net/mac80211/cfg.c: In function ‘ieee80211_probe_client’:
> > net/mac80211/cfg.c:2567:7: warning: ‘qos’ may be used uninitialized in this function
>
> Hm, you need a better compiler ;-) How about below instead (keeping the
> subject)? I kinda don't like just initialising the variable "randomly".
>
> johannes
>
>
> From: Johannes Berg <[email protected]>
>
> The warning is spurious -- if !sta we always exit without using the
> unassigned qos variable, and if we do find the sta we assign it.
>
> Signed-off-by: Johannes Berg <[email protected]>

Works for me...

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2011-11-11 19:24:44

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix warning in ieee80211_probe_client

On Fri, Nov 11, 2011 at 01:03:31PM -0600, Larry Finger wrote:
> On 11/11/2011 12:32 PM, John W. Linville wrote:
> > CC [M] net/mac80211/cfg.o
> >net/mac80211/cfg.c: In function ‘ieee80211_probe_client’:
> >net/mac80211/cfg.c:2567:7: warning: ‘qos’ may be used uninitialized in this function
> >
> >Signed-off-by: John W. Linville<[email protected]>
> >---
> > net/mac80211/cfg.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> >diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> >index c2416fb..1d82d2b 100644
> >--- a/net/mac80211/cfg.c
> >+++ b/net/mac80211/cfg.c
> >@@ -2564,7 +2564,7 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
> > struct sk_buff *skb;
> > int size = sizeof(*nullfunc);
> > __le16 fc;
> >- bool qos;
> >+ bool qos = NULL;
> > struct ieee80211_tx_info *info;
> > struct sta_info *sta;
>
> Shouldn't the initialization for a bool be "false"? Doesn't
> checkpatch.pl complain about that? I know it does if you try to
> initialize a pointer to 0 rather than NULL.

That's why we post patches to the list. :-)

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2011-11-11 19:03:35

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH] mac80211: fix warning in ieee80211_probe_client

On 11/11/2011 12:32 PM, John W. Linville wrote:
> CC [M] net/mac80211/cfg.o
> net/mac80211/cfg.c: In function ‘ieee80211_probe_client’:
> net/mac80211/cfg.c:2567:7: warning: ‘qos’ may be used uninitialized in this function
>
> Signed-off-by: John W. Linville<[email protected]>
> ---
> net/mac80211/cfg.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index c2416fb..1d82d2b 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -2564,7 +2564,7 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
> struct sk_buff *skb;
> int size = sizeof(*nullfunc);
> __le16 fc;
> - bool qos;
> + bool qos = NULL;
> struct ieee80211_tx_info *info;
> struct sta_info *sta;

Shouldn't the initialization for a bool be "false"? Doesn't checkpatch.pl
complain about that? I know it does if you try to initialize a pointer to 0
rather than NULL.

Larry