From: Kalle Valo <kvalo@codeaurora.org>
To: Brian Norris <briannorris@chromium.org>
Cc: srirrama@codeaurora.org, Arnd Bergmann <arnd@arndb.de>,
bpothuno@codeaurora.org, akolli@codeaurora.org,
linux-wireless@vger.kernel.org,
Linux Kernel <linux-kernel@vger.kernel.org>,
yintang@qti.qualcomm.com, pillair@codeaurora.org,
ath10k@lists.infradead.org, netdev@vger.kernel.org,
davem@davemloft.net
Subject: Re: [PATCH] ath10k: avoid -Wmaybe-uninitialized warning
Date: Fri, 16 Nov 2018 11:55:27 +0200 [thread overview]
Message-ID: <87sh0173e8.fsf@codeaurora.org> (raw)
In-Reply-To: <CA+ASDXPVJMge_B-AUXj1sKc4dB+3FcXew8T5FYEXVsncKYotiw@mail.gmail.com> (Brian Norris's message of "Fri, 2 Nov 2018 09:34:53 -0700")
Brian Norris <briannorris@chromium.org> writes:
> Hi,
>
> On Fri, Nov 2, 2018 at 9:19 AM Arnd Bergmann <arnd@arndb.de> wrote:
>>
>> In some configurations the inlining in gcc is suboptimal, causing
>> a false-positive warning:
>>
>> drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_mac_init_rd':
>> drivers/net/wireless/ath/ath10k/mac.c:8374:39: error: 'rd' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>> ar->ath_common.regulatory.current_rd = rd;
>>
>> If we initialize the output of ath10k_mac_get_wrdd_regulatory()
>> before returning, this problem goes away.
>>
>> Fixes: 209b2a68de76 ("ath10k: add platform regulatory domain support")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>> drivers/net/wireless/ath/ath10k/mac.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
>> index a1c2801ded10..0d5fde28ee44 100644
>> --- a/drivers/net/wireless/ath/ath10k/mac.c
>> +++ b/drivers/net/wireless/ath/ath10k/mac.c
>> @@ -8321,6 +8321,8 @@ static int ath10k_mac_get_wrdd_regulatory(struct ath10k *ar, u16 *rd)
>> u32 alpha2_code;
>> char alpha2[3];
>>
>> + *rd = ar->hw_eeprom_rd;
>> +
>
> Maybe it's just me, but it seems kinda weird for this function to
> assign a (valid) value to its "output" and still potentially return an
> error.
>
> If you really need to work around this compiler bug, maybe just put
> the eeprom assignment back in ath10k_mac_init_rd()? I'll leave it up
> to Kalle as to whether he wants to work around the compiler at all :)
In general I'm happy take workaround to compiler problems, I prefer to
keep ath10k warning free much as possible.
> Oh wait, one more thing: this is actually an invalid refactoring. See
> how this function assigns '*rd' later in error cases. Today, we still
> treat those as errors and clobber those with the eeprom value, but
> now, you're making the fallback case continue to use the erroneous
> value (0xffff). You need to make that use a local variable and avoid
> clobbering *rd, if you want this to be correct.
But I agree with Brian here, I don't think this patch is correct.
--
Kalle Valo
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k
WARNING: multiple messages have this Message-ID (diff)
From: Kalle Valo <kvalo@codeaurora.org>
To: Brian Norris <briannorris@chromium.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
srirrama@codeaurora.org, bpothuno@codeaurora.org,
akolli@codeaurora.org, linux-wireless@vger.kernel.org,
Linux Kernel <linux-kernel@vger.kernel.org>,
yintang@qti.qualcomm.com, pillair@codeaurora.org,
ath10k@lists.infradead.org, netdev@vger.kernel.org,
davem@davemloft.net
Subject: Re: [PATCH] ath10k: avoid -Wmaybe-uninitialized warning
Date: Fri, 16 Nov 2018 11:55:27 +0200 [thread overview]
Message-ID: <87sh0173e8.fsf@codeaurora.org> (raw)
In-Reply-To: <CA+ASDXPVJMge_B-AUXj1sKc4dB+3FcXew8T5FYEXVsncKYotiw@mail.gmail.com> (Brian Norris's message of "Fri, 2 Nov 2018 09:34:53 -0700")
Brian Norris <briannorris@chromium.org> writes:
> Hi,
>
> On Fri, Nov 2, 2018 at 9:19 AM Arnd Bergmann <arnd@arndb.de> wrote:
>>
>> In some configurations the inlining in gcc is suboptimal, causing
>> a false-positive warning:
>>
>> drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_mac_init_rd':
>> drivers/net/wireless/ath/ath10k/mac.c:8374:39: error: 'rd' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>> ar->ath_common.regulatory.current_rd = rd;
>>
>> If we initialize the output of ath10k_mac_get_wrdd_regulatory()
>> before returning, this problem goes away.
>>
>> Fixes: 209b2a68de76 ("ath10k: add platform regulatory domain support")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>> drivers/net/wireless/ath/ath10k/mac.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
>> index a1c2801ded10..0d5fde28ee44 100644
>> --- a/drivers/net/wireless/ath/ath10k/mac.c
>> +++ b/drivers/net/wireless/ath/ath10k/mac.c
>> @@ -8321,6 +8321,8 @@ static int ath10k_mac_get_wrdd_regulatory(struct ath10k *ar, u16 *rd)
>> u32 alpha2_code;
>> char alpha2[3];
>>
>> + *rd = ar->hw_eeprom_rd;
>> +
>
> Maybe it's just me, but it seems kinda weird for this function to
> assign a (valid) value to its "output" and still potentially return an
> error.
>
> If you really need to work around this compiler bug, maybe just put
> the eeprom assignment back in ath10k_mac_init_rd()? I'll leave it up
> to Kalle as to whether he wants to work around the compiler at all :)
In general I'm happy take workaround to compiler problems, I prefer to
keep ath10k warning free much as possible.
> Oh wait, one more thing: this is actually an invalid refactoring. See
> how this function assigns '*rd' later in error cases. Today, we still
> treat those as errors and clobber those with the eeprom value, but
> now, you're making the fallback case continue to use the erroneous
> value (0xffff). You need to make that use a local variable and avoid
> clobbering *rd, if you want this to be correct.
But I agree with Brian here, I don't think this patch is correct.
--
Kalle Valo
next prev parent reply other threads:[~2018-11-16 9:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-02 16:17 [PATCH] ath10k: avoid -Wmaybe-uninitialized warning Arnd Bergmann
2018-11-02 16:17 ` Arnd Bergmann
2018-11-02 16:34 ` Brian Norris
2018-11-02 16:34 ` Brian Norris
2018-11-16 9:55 ` Kalle Valo [this message]
2018-11-16 9:55 ` Kalle Valo
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=87sh0173e8.fsf@codeaurora.org \
--to=kvalo@codeaurora.org \
--cc=akolli@codeaurora.org \
--cc=arnd@arndb.de \
--cc=ath10k@lists.infradead.org \
--cc=bpothuno@codeaurora.org \
--cc=briannorris@chromium.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pillair@codeaurora.org \
--cc=srirrama@codeaurora.org \
--cc=yintang@qti.qualcomm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.