linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Mahoney <jeffm@suse.com>
To: Johannes Berg <johannes@sipsolutions.net>,
	linux-wireless@vger.kernel.org
Subject: Re: [PATCH] mac80211: fix "warning: ‘target_metric’ may be used uninitialized"
Date: Tue, 5 Apr 2016 09:47:05 -0400	[thread overview]
Message-ID: <5703C1D9.2000800@suse.com> (raw)
In-Reply-To: <1459863619.18188.50.camel@sipsolutions.net>


[-- Attachment #1.1: Type: text/plain, Size: 1372 bytes --]

On 4/5/16 9:40 AM, Johannes Berg wrote:
> On Tue, 2016-04-05 at 09:33 -0400, Jeff Mahoney wrote:
>> On 4/5/16 5:43 AM, Johannes Berg wrote:
>>>
>>> On Mon, 2016-04-04 at 14:15 -0400, Jeff Mahoney wrote:
>>>>
>>>> This fixes:
>>>>
>>>> net/mac80211/mesh_hwmp.c:603:26: warning: ‘target_metric’ may be
>>>> used
>>>> uninitialized in this function
>>>>
>>>> target_metric is only consumed when reply = true so no bug exists
>>>> here,
>>>> but gcc doesn't notice that.  Initializing to 0 clears the
>>>> warning.
>>>>
>>> What gcc version are you using? Mine doesn't seem to have a problem
>>> following the logic here.
>> gcc version 4.8.5 (SUSE Linux)
> 
> Ok, mine's significantly newer:
> 
> gcc (Debian 5.3.1-10) 5.3.1 20160224
> 
> I do wonder though if we really should do this? It might hide errors
> later on?

AFAICT, the only way errors would be introduced is if someone added a
new case in which reply was true *and* needed a different target_metric
value (there are 3 cases it's used, 2 of which use 0).  Or if there was
a new case where the target_metric was used and reply wasn't true -- in
which case this code would have been broken anyway.

Also, using uninitalized_var would have a higher probability of hiding
an error later on.  Setting it to 0 seems the safest course.

-Jeff

-- 
Jeff Mahoney
SUSE Labs


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 881 bytes --]

  reply	other threads:[~2016-04-05 13:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-04 18:15 [PATCH] mac80211: fix "warning: ‘target_metric’ may be used uninitialized" Jeff Mahoney
2016-04-05  9:43 ` Johannes Berg
2016-04-05 13:33   ` Jeff Mahoney
2016-04-05 13:40     ` Johannes Berg
2016-04-05 13:47       ` Jeff Mahoney [this message]
2016-04-06 13:14 ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5703C1D9.2000800@suse.com \
    --to=jeffm@suse.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).