public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/ca0132: work around clang -Wuninitialized warning
@ 2019-03-22 14:06 Arnd Bergmann
  2019-03-22 14:53 ` Nathan Chancellor
  2019-03-22 15:00 ` Takashi Iwai
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2019-03-22 14:06 UTC (permalink / raw)
  To: Takashi Iwai, Connor McAdams, Takashi Sakamoto
  Cc: clang-built-linux, Nick Desaulniers, Nathan Chancellor,
	Arnd Bergmann, Jaroslav Kysela, Alastair Bridgewater, alsa-devel,
	linux-kernel

When CONFIG_PCI is disabled, clang gets confused about the
control flow of the switch() statement always ending up
in the default case, and warns:

sound/pci/hda/patch_ca0132.c:7558:6: error: variable 'fw_entry' is used uninitialized whenever 'if' condition is false
      [-Werror,-Wsometimes-uninitialized]
        if (!spec->alt_firmware_present) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/pci/hda/patch_ca0132.c:7565:42: note: uninitialized use occurs here
        dsp_os_image = (struct dsp_image_seg *)(fw_entry->data);
                                                ^~~~~~~~
sound/pci/hda/patch_ca0132.c:7558:2: note: remove the 'if' if its condition is always true
        if (!spec->alt_firmware_present) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/pci/hda/patch_ca0132.c:7521:33: note: initialize the variable 'fw_entry' to silence this warning
        const struct firmware *fw_entry;
                                       ^
                                        = NULL

Adding an explicit check for CONFIG_PCI avoids the issue.
Unfortunately this is not very intuitive here.

Link: https://bugs.llvm.org/show_bug.cgi?id=41197#c1
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Any suggestions for other workarounds appreciated. If you can think
of a better fix, please treat this as a reported-by:
---
 sound/pci/hda/patch_ca0132.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 29882bda7632..415b16b7db70 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -7555,7 +7555,7 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec)
 	 * Use default ctefx.bin if no alt firmware is detected, or if none
 	 * exists for your particular codec.
 	 */
-	if (!spec->alt_firmware_present) {
+	if (!IS_ENABLED(CONFIG_PCI) || !spec->alt_firmware_present) {
 		codec_dbg(codec, "Default firmware selected.");
 		if (request_firmware(&fw_entry, EFX_FILE,
 					codec->card->dev) != 0)
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-22 15:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-22 14:06 [PATCH] ALSA: hda/ca0132: work around clang -Wuninitialized warning Arnd Bergmann
2019-03-22 14:53 ` Nathan Chancellor
2019-03-22 15:00 ` Takashi Iwai
2019-03-22 15:12   ` Arnd Bergmann
2019-03-22 15:13   ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox