All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: Connor McAdams <conmanx360@gmail.com>,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>,
	ALSA Development Mailing List <alsa-devel@alsa-project.org>,
	Alastair Bridgewater <alastair.bridgewater@gmail.com>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	clang-built-linux@googlegroups.com,
	Jaroslav Kysela <perex@perex.cz>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ALSA: hda/ca0132: work around clang -Wuninitialized warning
Date: Fri, 22 Mar 2019 16:12:42 +0100	[thread overview]
Message-ID: <CAK8P3a0DdQ2dgbgCDvwD37uu=_iU7VGOWHN+6tp=CxeSzz8GtQ@mail.gmail.com> (raw)
In-Reply-To: <s5hr2az9cos.wl-tiwai@suse.de>

On Fri, Mar 22, 2019 at 4:00 PM Takashi Iwai <tiwai@suse.de> wrote:
>
> On Fri, 22 Mar 2019 15:06:28 +0100,
> Arnd Bergmann wrote:
> >
> > 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:
>
> Can it be addressed by the code simplification like below, instead?
>

Yes, I confirmed this works as well, and it's probably more
obvious what's going on, so let's use your version.

Thanks,

      Arnd

  reply	other threads:[~2019-03-22 15:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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:00   ` Takashi Iwai
2019-03-22 15:12   ` Arnd Bergmann [this message]
2019-03-22 15:13   ` Nathan Chancellor

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='CAK8P3a0DdQ2dgbgCDvwD37uu=_iU7VGOWHN+6tp=CxeSzz8GtQ@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=alastair.bridgewater@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=conmanx360@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=o-takashi@sakamocchi.jp \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /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.