From: Luca Coelho <luca@coelho.fi>
To: Arnd Bergmann <arnd@arndb.de>, Johannes Berg <johannes.berg@intel.com>
Cc: clang-built-linux@googlegroups.com,
Nick Desaulniers <ndesaulniers@google.com>,
Nathan Chancellor <natechancellor@gmail.com>,
Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
Intel Linux Wireless <linuxwifi@intel.com>,
Kalle Valo <kvalo@codeaurora.org>,
"David S. Miller" <davem@davemloft.net>,
Sara Sharon <sara.sharon@intel.com>,
Avraham Stern <avraham.stern@intel.com>,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iwlwifi: work around clang -Wuninitialized warning
Date: Sat, 23 Mar 2019 08:11:10 +0200 [thread overview]
Message-ID: <a92bc0994d5f3fa5da5da471d0ccd01f8cefeee5.camel@coelho.fi> (raw)
In-Reply-To: <20190322141322.463149-1-arnd@arndb.de>
On Fri, 2019-03-22 at 15:13 +0100, Arnd Bergmann wrote:
> Clang incorrectly warns about an uninitialized variable:
>
> drivers/net/wireless/intel/iwlwifi/mvm/sta.c:2114:12: error: variable
> 'queue' is used uninitialized whenever 'if'
> condition is false [-Werror,-Wsometimes-uninitialized]
> else if (WARN(1, "Missing required TXQ for adding
> bcast STA\n"))
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~
> include/asm-generic/bug.h:130:36: note: expanded from macro 'WARN'
> #define WARN(condition, format...)
> ({ \
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~
> drivers/net/wireless/intel/iwlwifi/mvm/sta.c:2119:33: note:
> uninitialized use occurs here
> iwl_mvm_enable_txq(mvm, NULL, queue, 0, &cfg,
> wdg_timeout);
> ^~~~~
> drivers/net/wireless/intel/iwlwifi/mvm/sta.c:2114:8: note: remove the
> 'if' if its condition is always true
> else if (WARN(1, "Missing required TXQ for adding
> bcast STA\n"))
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~
> drivers/net/wireless/intel/iwlwifi/mvm/sta.c:2094:11: note:
> initialize the variable 'queue' to silence this warning
> int queue;
> ^
> = 0
> 1 error generated.
>
> This cannot happen because the if/else if/else if block always
> has one code path that is entered. However, we can simply
> rearrange the code to let clang see this as well.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
Thanks for the patch, Arnd! But I have already queued up an equivalent
patch for v5.2 (should probably reach linux-next by the end of next
week or so):
https://patchwork.kernel.org/patch/10844025/
--
Cheers,
Luca.
next prev parent reply other threads:[~2019-03-23 6:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-22 14:13 Arnd Bergmann
2019-03-23 6:11 ` Luca Coelho [this message]
2019-03-23 11:28 ` Arnd Bergmann
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=a92bc0994d5f3fa5da5da471d0ccd01f8cefeee5.camel@coelho.fi \
--to=luca@coelho.fi \
--cc=arnd@arndb.de \
--cc=avraham.stern@intel.com \
--cc=clang-built-linux@googlegroups.com \
--cc=davem@davemloft.net \
--cc=emmanuel.grumbach@intel.com \
--cc=johannes.berg@intel.com \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linuxwifi@intel.com \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=sara.sharon@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®