Re: [PATCH] ALSA: hda: tas2781-spi: Fix -Wsometimes-uninitialized in tasdevice_spi_switch_book()

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



On Mon, 20 Jan 2025 14:32:48 +0100,
Nathan Chancellor wrote:
> 
> Clang warns (or errors with CONFIG_WERROR=y):
> 
>   sound/pci/hda/tas2781_hda_spi.c:110:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>     110 |         if (tas_priv->cur_book != TASDEVICE_BOOK_ID(reg)) {
>         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   sound/pci/hda/tas2781_hda_spi.c:119:9: note: uninitialized use occurs here
>     119 |         return ret;
>         |                ^~~
>   sound/pci/hda/tas2781_hda_spi.c:110:2: note: remove the 'if' if its condition is always true
>     110 |         if (tas_priv->cur_book != TASDEVICE_BOOK_ID(reg)) {
>         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   sound/pci/hda/tas2781_hda_spi.c:108:9: note: initialize the variable 'ret' to silence this warning
>     108 |         int ret;
>         |                ^
>         |                 = 0
> 
> Sink the declaration of ret into the if block and just return 0 at the
> end of the function, as there is nothing to do if cur_book has already
> been changed.
> 
> Fixes: bb5f86ea50ff ("ALSA: hda/tas2781: Add tas2781 hda SPI driver")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202501192006.Hm9GmKiV-lkp@xxxxxxxxx/
> Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>

Thanks, applied now.


Takashi




[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux