diff mbox series

[1/4] ASoC: aw88261: Fix unitialized ret of aw88261_reg_update()

Message ID 20230810104749.164827-1-krzysztof.kozlowski@linaro.org (mailing list archive)
State New, archived
Headers show
Series [1/4] ASoC: aw88261: Fix unitialized ret of aw88261_reg_update() | expand

Commit Message

Krzysztof Kozlowski Aug. 10, 2023, 10:47 a.m. UTC
There is a branch in if() clause where aw88261_reg_update() could return
uninitialized value.  Pounted out by W=1 clang build:

  sound/soc/codecs/aw88261.c:651:7: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                if (aw_dev->prof_cur != aw_dev->prof_index) {
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  sound/soc/codecs/aw88261.c:660:9: note: uninitialized use occurs here
        return ret;
               ^~~
  sound/soc/codecs/aw88261.c:651:3: note: remove the 'if' if its condition is always true
                if (aw_dev->prof_cur != aw_dev->prof_index) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 sound/soc/codecs/aw88261.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nick Desaulniers Aug. 14, 2023, 10:02 p.m. UTC | #1
On Thu, Aug 10, 2023 at 3:47 AM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
>
> There is a branch in if() clause where aw88261_reg_update() could return
> uninitialized value.  Pounted out by W=1 clang build:
>
>   sound/soc/codecs/aw88261.c:651:7: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>                 if (aw_dev->prof_cur != aw_dev->prof_index) {
>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   sound/soc/codecs/aw88261.c:660:9: note: uninitialized use occurs here
>         return ret;
>                ^~~
>   sound/soc/codecs/aw88261.c:651:3: note: remove the 'if' if its condition is always true
>                 if (aw_dev->prof_cur != aw_dev->prof_index) {
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks for the patch!
I see this addressed already in -next:
https://lore.kernel.org/all/20230808125703.1611325-1-arnd@kernel.org/


>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  sound/soc/codecs/aw88261.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c
> index 82923b454dd4..fddba2f2de41 100644
> --- a/sound/soc/codecs/aw88261.c
> +++ b/sound/soc/codecs/aw88261.c
> @@ -636,7 +636,7 @@ static int aw88261_dev_stop(struct aw_device *aw_dev)
>  static int aw88261_reg_update(struct aw88261 *aw88261, bool force)
>  {
>         struct aw_device *aw_dev = aw88261->aw_pa;
> -       int ret;
> +       int ret = 0;
>
>         if (force) {
>                 ret = regmap_write(aw_dev->regmap,
> --
> 2.34.1
>
Mark Brown Aug. 15, 2023, 2:10 p.m. UTC | #2
On Thu, Aug 10, 2023 at 12:47:43PM +0200, Krzysztof Kozlowski wrote:
> There is a branch in if() clause where aw88261_reg_update() could return
> uninitialized value.  Pounted out by W=1 clang build:

This series appears to have two copies of every patch which *look*
similar but I'm not 100% sure if that's the case or in general what's
going on - could you please resend a clean copy, it's probably easier
than figuring it out?
Krzysztof Kozlowski Aug. 15, 2023, 2:21 p.m. UTC | #3
On 15/08/2023 16:10, Mark Brown wrote:
> On Thu, Aug 10, 2023 at 12:47:43PM +0200, Krzysztof Kozlowski wrote:
>> There is a branch in if() clause where aw88261_reg_update() could return
>> uninitialized value.  Pounted out by W=1 clang build:
> 
> This series appears to have two copies of every patch which *look*
> similar but I'm not 100% sure if that's the case or in general what's
> going on - could you please resend a clean copy, it's probably easier
> than figuring it out?

Sorry for that, I must have screwed something while sending. I'll rebase
(first patch seems to be already fixed by Arnd) and send again.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c
index 82923b454dd4..fddba2f2de41 100644
--- a/sound/soc/codecs/aw88261.c
+++ b/sound/soc/codecs/aw88261.c
@@ -636,7 +636,7 @@  static int aw88261_dev_stop(struct aw_device *aw_dev)
 static int aw88261_reg_update(struct aw88261 *aw88261, bool force)
 {
 	struct aw_device *aw_dev = aw88261->aw_pa;
-	int ret;
+	int ret = 0;
 
 	if (force) {
 		ret = regmap_write(aw_dev->regmap,