[PATCH-next V2] ASoC: rt721-sdca: Clean logically deadcode in rt721-sdca.c

Everest K.C. posted 1 patch 1 month, 2 weeks ago
sound/soc/codecs/rt721-sdca.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
[PATCH-next V2] ASoC: rt721-sdca: Clean logically deadcode in rt721-sdca.c
Posted by Everest K.C. 1 month, 2 weeks ago
As the same condition was checked in inner and outer if
statements. The code never reaches the inner else statement.

This issue was reported by Coverity Scan with CID = 1600271.

Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
---
V1 -> V2: - Updated the patch prefix to PATCH-next
	  - Added how the issue was discovered 

 sound/soc/codecs/rt721-sdca.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/rt721-sdca.c b/sound/soc/codecs/rt721-sdca.c
index 36056cb7a3ca..4fd26e490610 100644
--- a/sound/soc/codecs/rt721-sdca.c
+++ b/sound/soc/codecs/rt721-sdca.c
@@ -611,13 +611,9 @@ static int rt721_sdca_dmic_set_gain_get(struct snd_kcontrol *kcontrol,
 
 		if (!adc_vol_flag) /* boost gain */
 			ctl = regvalue / boost_step;
-		else { /* ADC gain */
-			if (adc_vol_flag)
-				ctl = p->max - (((vol_max - regvalue) & 0xffff) / interval_offset);
-			else
-				ctl = p->max - (((0 - regvalue) & 0xffff) / interval_offset);
-		}
-
+		else /* ADC gain */
+			ctl = p->max - (((vol_max - regvalue) & 0xffff) / interval_offset);
+
 		ucontrol->value.integer.value[i] = ctl;
 	}
 
-- 
2.43.0
Re: [PATCH-next V2] ASoC: rt721-sdca: Clean logically deadcode in rt721-sdca.c
Posted by Shuah Khan 1 month, 2 weeks ago
On 10/8/24 17:44, Everest K.C. wrote:
> As the same condition was checked in inner and outer if
> statements. The code never reaches the inner else statement.
> 
> This issue was reported by Coverity Scan with CID = 1600271.
> 
> Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
> ---
> V1 -> V2: - Updated the patch prefix to PATCH-next
> 	  - Added how the issue was discovered
> 
>   sound/soc/codecs/rt721-sdca.c | 10 +++-------
>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/soc/codecs/rt721-sdca.c b/sound/soc/codecs/rt721-sdca.c
> index 36056cb7a3ca..4fd26e490610 100644
> --- a/sound/soc/codecs/rt721-sdca.c
> +++ b/sound/soc/codecs/rt721-sdca.c
> @@ -611,13 +611,9 @@ static int rt721_sdca_dmic_set_gain_get(struct snd_kcontrol *kcontrol,
>   
>   		if (!adc_vol_flag) /* boost gain */
>   			ctl = regvalue / boost_step;
> -		else { /* ADC gain */
> -			if (adc_vol_flag)
> -				ctl = p->max - (((vol_max - regvalue) & 0xffff) / interval_offset);
> -			else
> -				ctl = p->max - (((0 - regvalue) & 0xffff) / interval_offset);
> -		}
> -
> +		else /* ADC gain */
> +			ctl = p->max - (((vol_max - regvalue) & 0xffff) / interval_offset);
> +
>   		ucontrol->value.integer.value[i] = ctl;
>   	}
>   


Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

As mentioned in my review for v1 of this patch, the exact same problem
exists in sound/soc/codecs/rt722-sdca.c as well, in case you want to send
patch to fix that one.

thanks,
-- Shuah
Re: [PATCH-next V2] ASoC: rt721-sdca: Clean logically deadcode in rt721-sdca.c
Posted by Everest K.C. 1 month, 2 weeks ago
On Thu, Oct 10, 2024 at 9:08 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 10/8/24 17:44, Everest K.C. wrote:
> > As the same condition was checked in inner and outer if
> > statements. The code never reaches the inner else statement.
> >
> > This issue was reported by Coverity Scan with CID = 1600271.
> >
> > Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
> > ---
> > V1 -> V2: - Updated the patch prefix to PATCH-next
> >         - Added how the issue was discovered
> >
> >   sound/soc/codecs/rt721-sdca.c | 10 +++-------
> >   1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/sound/soc/codecs/rt721-sdca.c b/sound/soc/codecs/rt721-sdca.c
> > index 36056cb7a3ca..4fd26e490610 100644
> > --- a/sound/soc/codecs/rt721-sdca.c
> > +++ b/sound/soc/codecs/rt721-sdca.c
> > @@ -611,13 +611,9 @@ static int rt721_sdca_dmic_set_gain_get(struct snd_kcontrol *kcontrol,
> >
> >               if (!adc_vol_flag) /* boost gain */
> >                       ctl = regvalue / boost_step;
> > -             else { /* ADC gain */
> > -                     if (adc_vol_flag)
> > -                             ctl = p->max - (((vol_max - regvalue) & 0xffff) / interval_offset);
> > -                     else
> > -                             ctl = p->max - (((0 - regvalue) & 0xffff) / interval_offset);
> > -             }
> > -
> > +             else /* ADC gain */
> > +                     ctl = p->max - (((vol_max - regvalue) & 0xffff) / interval_offset);
> > +
> >               ucontrol->value.integer.value[i] = ctl;
> >       }
> >
>
>
> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
>
> As mentioned in my review for v1 of this patch, the exact same problem
> exists in sound/soc/codecs/rt722-sdca.c as well, in case you want to send
> patch to fix that one.
I just sent the patch for it as well. Thank you for pointing it out.
> thanks,
> -- Shuah
Thanks,
Everest K.C.
Re: [PATCH-next V2] ASoC: rt721-sdca: Clean logically deadcode in rt721-sdca.c
Posted by Mark Brown 1 month, 2 weeks ago
On Tue, 08 Oct 2024 17:44:20 -0600, Everest K.C. wrote:
> As the same condition was checked in inner and outer if
> statements. The code never reaches the inner else statement.
> 
> This issue was reported by Coverity Scan with CID = 1600271.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: rt721-sdca: Clean logically deadcode in rt721-sdca.c
      commit: 8658c4eb9d6b76311322c1b74b3d4e0dec3599d8

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark