Search Linux Wireless

Re: [PATCH] iwlwifi: work around clang -Wuninitialized warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
> ---

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.




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux