linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nl80211: avoid "wdev_id may be used uninitialized"
@ 2013-01-30  0:11 Stephen Warren
  2013-01-30  7:57 ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2013-01-30  0:11 UTC (permalink / raw)
  To: Johannes Berg, John W. Linville, David S. Miller
  Cc: linux-wireless, netdev, linux-kernel, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

Silence the following:
net/wireless/nl80211.c: In function '__cfg80211_wdev_from_attrs.clone.119':
net/wireless/nl80211.c:57:6: warning: 'wdev_id' may be used uninitialized in this function

... by always initializing wdev_id to zero. I assume that wiphy_idx and
ifidx are set to -1 for similar reasons, so this change simply propagates
the same workaround.

In practice, this warning is false, since wdev_id is both set and used
under the condition if (have_wdev_id). However, at least my compiler
can't be coerced into realizing this; almost any code between the if
blocks that set and use the variable causes this warning.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 net/wireless/nl80211.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 33de803..389e62a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -54,7 +54,7 @@ __cfg80211_wdev_from_attrs(struct net *netns, struct nlattr **attrs)
 	struct wireless_dev *result = NULL;
 	bool have_ifidx = attrs[NL80211_ATTR_IFINDEX];
 	bool have_wdev_id = attrs[NL80211_ATTR_WDEV];
-	u64 wdev_id;
+	u64 wdev_id = 0;
 	int wiphy_idx = -1;
 	int ifidx = -1;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] nl80211: avoid "wdev_id may be used uninitialized"
  2013-01-30  0:11 [PATCH] nl80211: avoid "wdev_id may be used uninitialized" Stephen Warren
@ 2013-01-30  7:57 ` Johannes Berg
  2013-01-30 16:49   ` Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2013-01-30  7:57 UTC (permalink / raw)
  To: Stephen Warren
  Cc: John W. Linville, David S. Miller, linux-wireless, netdev,
	linux-kernel, Stephen Warren

On Tue, 2013-01-29 at 17:11 -0700, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Silence the following:
> net/wireless/nl80211.c: In function '__cfg80211_wdev_from_attrs.clone.119':
> net/wireless/nl80211.c:57:6: warning: 'wdev_id' may be used uninitialized in this function
> 
> ... by always initializing wdev_id to zero. I assume that wiphy_idx and
> ifidx are set to -1 for similar reasons, so this change simply propagates
> the same workaround.
> 
> In practice, this warning is false, since wdev_id is both set and used
> under the condition if (have_wdev_id). However, at least my compiler
> can't be coerced into realizing this; almost any code between the if
> blocks that set and use the variable causes this warning.

I don't see this warning? What compiler are you using?

johannes


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nl80211: avoid "wdev_id may be used uninitialized"
  2013-01-30  7:57 ` Johannes Berg
@ 2013-01-30 16:49   ` Stephen Warren
  2013-01-31 20:51     ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2013-01-30 16:49 UTC (permalink / raw)
  To: Johannes Berg
  Cc: John W. Linville, David S. Miller, linux-wireless, netdev,
	linux-kernel, Stephen Warren

On 01/30/2013 12:57 AM, Johannes Berg wrote:
> On Tue, 2013-01-29 at 17:11 -0700, Stephen Warren wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> Silence the following:
>> net/wireless/nl80211.c: In function '__cfg80211_wdev_from_attrs.clone.119':
>> net/wireless/nl80211.c:57:6: warning: 'wdev_id' may be used uninitialized in this function
>>
>> ... by always initializing wdev_id to zero. I assume that wiphy_idx and
>> ifidx are set to -1 for similar reasons, so this change simply propagates
>> the same workaround.
>>
>> In practice, this warning is false, since wdev_id is both set and used
>> under the condition if (have_wdev_id). However, at least my compiler
>> can't be coerced into realizing this; almost any code between the if
>> blocks that set and use the variable causes this warning.
> 
> I don't see this warning? What compiler are you using?

I'm using gcc-4.5.3 for ARM. I checked with gcc-4.6.3 and gcc-4.7.2 and
indeed I don't see the warning there.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nl80211: avoid "wdev_id may be used uninitialized"
  2013-01-30 16:49   ` Stephen Warren
@ 2013-01-31 20:51     ` Johannes Berg
  2013-01-31 22:21       ` Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2013-01-31 20:51 UTC (permalink / raw)
  To: Stephen Warren
  Cc: John W. Linville, David S. Miller, linux-wireless, netdev,
	linux-kernel, Stephen Warren

On Wed, 2013-01-30 at 09:49 -0700, Stephen Warren wrote:
> On 01/30/2013 12:57 AM, Johannes Berg wrote:
> > On Tue, 2013-01-29 at 17:11 -0700, Stephen Warren wrote:
> >> From: Stephen Warren <swarren@nvidia.com>
> >>
> >> Silence the following:
> >> net/wireless/nl80211.c: In function '__cfg80211_wdev_from_attrs.clone.119':
> >> net/wireless/nl80211.c:57:6: warning: 'wdev_id' may be used uninitialized in this function
> >>
> >> ... by always initializing wdev_id to zero. I assume that wiphy_idx and
> >> ifidx are set to -1 for similar reasons, so this change simply propagates
> >> the same workaround.
> >>
> >> In practice, this warning is false, since wdev_id is both set and used
> >> under the condition if (have_wdev_id). However, at least my compiler
> >> can't be coerced into realizing this; almost any code between the if
> >> blocks that set and use the variable causes this warning.
> > 
> > I don't see this warning? What compiler are you using?
> 
> I'm using gcc-4.5.3 for ARM. I checked with gcc-4.6.3 and gcc-4.7.2 and
> indeed I don't see the warning there.

Interesting. So should I keep it or remove it? I guess in this
particular instance it doesn't matter all that much. In other cases I'd
be more against changing it I guess.

johannes


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nl80211: avoid "wdev_id may be used uninitialized"
  2013-01-31 20:51     ` Johannes Berg
@ 2013-01-31 22:21       ` Stephen Warren
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2013-01-31 22:21 UTC (permalink / raw)
  To: Johannes Berg
  Cc: John W. Linville, David S. Miller, linux-wireless, netdev,
	linux-kernel, Stephen Warren

On 01/31/2013 01:51 PM, Johannes Berg wrote:
> On Wed, 2013-01-30 at 09:49 -0700, Stephen Warren wrote:
>> On 01/30/2013 12:57 AM, Johannes Berg wrote:
>>> On Tue, 2013-01-29 at 17:11 -0700, Stephen Warren wrote:
>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>
>>>> Silence the following:
>>>> net/wireless/nl80211.c: In function '__cfg80211_wdev_from_attrs.clone.119':
>>>> net/wireless/nl80211.c:57:6: warning: 'wdev_id' may be used uninitialized in this function
>>>>
>>>> ... by always initializing wdev_id to zero. I assume that wiphy_idx and
>>>> ifidx are set to -1 for similar reasons, so this change simply propagates
>>>> the same workaround.
>>>>
>>>> In practice, this warning is false, since wdev_id is both set and used
>>>> under the condition if (have_wdev_id). However, at least my compiler
>>>> can't be coerced into realizing this; almost any code between the if
>>>> blocks that set and use the variable causes this warning.
>>>
>>> I don't see this warning? What compiler are you using?
>>
>> I'm using gcc-4.5.3 for ARM. I checked with gcc-4.6.3 and gcc-4.7.2 and
>> indeed I don't see the warning there.
> 
> Interesting. So should I keep it or remove it? I guess in this
> particular instance it doesn't matter all that much. In other cases I'd
> be more against changing it I guess.

It's your call. I guess since it's fixed going forward in gcc, you may
as well drop it though.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-31 22:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-30  0:11 [PATCH] nl80211: avoid "wdev_id may be used uninitialized" Stephen Warren
2013-01-30  7:57 ` Johannes Berg
2013-01-30 16:49   ` Stephen Warren
2013-01-31 20:51     ` Johannes Berg
2013-01-31 22:21       ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).