All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Nathan Chancellor <nathan@kernel.org>
Cc: g@b4.vu, tiwai@suse.com, alsa-devel@alsa-project.org,
	linux-sound@vger.kernel.org, llvm@lists.linux.dev,
	patches@lists.linux.dev
Subject: Re: [PATCH] ALSA: scarlett2: Zero initialize ret in scarlett2_ag_target_ctl_get()
Date: Sun, 21 Apr 2024 19:32:23 +0200	[thread overview]
Message-ID: <87a5lm4o60.wl-tiwai@suse.de> (raw)
In-Reply-To: <20240419-alsa-scarlett2-fix-wsometimes-uninitialized-v1-1-e2ace8642e08@kernel.org>

On Sat, 20 Apr 2024 02:25:59 +0200,
Nathan Chancellor wrote:
> 
> Clang warns (or errors with CONFIG_WERROR):
> 
>   sound/usb/mixer_scarlett2.c:3697:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>    3697 |         if (private->autogain_updated) {
>         |             ^~~~~~~~~~~~~~~~~~~~~~~~~
>   sound/usb/mixer_scarlett2.c:3707:9: note: uninitialized use occurs here
>    3707 |         return err;
>         |                ^~~
>   sound/usb/mixer_scarlett2.c:3697:2: note: remove the 'if' if its condition is always true
>    3697 |         if (private->autogain_updated) {
>         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   sound/usb/mixer_scarlett2.c:3688:9: note: initialize the variable 'err' to silence this warning
>    3688 |         int err;
>         |                ^
>         |                 = 0
>   1 error generated.
> 
> Initialize ret to zero to ensure ret is initialized in all paths within
> scarlett2_ag_target_ctl_get(), which matches the style of other
> functions in this driver.
> 
> Fixes: e30ea5340c25 ("ALSA: scarlett2: Add autogain target controls")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Thanks, applied now.

> ---
> FWIW, a lot of the functions that end in just 'mutex_unlock()' before
> returning could probably benefit from the cleanup.h infrastructure,
> which would help with the scope of err in this particular function, but
> I decided to go with the most minimal fix here.

Yeah, we can clean up lots of such code now.

If it were a new code file, I'd suggest it, but since it was an
extention of the existing code, I accepted as is.


thanks,

Takashi

      reply	other threads:[~2024-04-21 17:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20  0:25 [PATCH] ALSA: scarlett2: Zero initialize ret in scarlett2_ag_target_ctl_get() Nathan Chancellor
2024-04-21 17:32 ` Takashi Iwai [this message]

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=87a5lm4o60.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=g@b4.vu \
    --cc=linux-sound@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=tiwai@suse.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 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.