2021-03-12 18:24:36

by Pierre-Louis Bossart

[permalink] [raw]
Subject: [PATCH 02/23] ASoC: ad1836: remove useless return

Cppcheck warning:

sound/soc/codecs/ad1836.c:311:9: warning: Identical condition and return expression 'ret', return value is always 0 [identicalConditionAfterEarlyExit]
return ret;
^
sound/soc/codecs/ad1836.c:308:6: note: If condition 'ret' is true, the function will return/exit
if (ret)
^
sound/soc/codecs/ad1836.c:311:9: note: Returning identical expression 'ret'
return ret;
^

Likely copy/paste between adc and dac cases.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
---
sound/soc/codecs/ad1836.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c
index a46152560294..08a5651bed9f 100644
--- a/sound/soc/codecs/ad1836.c
+++ b/sound/soc/codecs/ad1836.c
@@ -305,8 +305,6 @@ static int ad1836_probe(struct snd_soc_component *component)
return ret;

ret = snd_soc_dapm_add_routes(dapm, ad183x_adc_routes, num_adcs);
- if (ret)
- return ret;

return ret;
}
--
2.25.1


2021-03-12 18:52:44

by Lars-Peter Clausen

[permalink] [raw]
Subject: Re: [PATCH 02/23] ASoC: ad1836: remove useless return

On 3/12/21 7:22 PM, Pierre-Louis Bossart wrote:
> Cppcheck warning:
>
> sound/soc/codecs/ad1836.c:311:9: warning: Identical condition and return expression 'ret', return value is always 0 [identicalConditionAfterEarlyExit]
> return ret;
> ^
> sound/soc/codecs/ad1836.c:308:6: note: If condition 'ret' is true, the function will return/exit
> if (ret)
> ^
> sound/soc/codecs/ad1836.c:311:9: note: Returning identical expression 'ret'
> return ret;
> ^
>
> Likely copy/paste between adc and dac cases.
>
> Signed-off-by: Pierre-Louis Bossart <[email protected]>
> ---
> sound/soc/codecs/ad1836.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c
> index a46152560294..08a5651bed9f 100644
> --- a/sound/soc/codecs/ad1836.c
> +++ b/sound/soc/codecs/ad1836.c
> @@ -305,8 +305,6 @@ static int ad1836_probe(struct snd_soc_component *component)
> return ret;
>
> ret = snd_soc_dapm_add_routes(dapm, ad183x_adc_routes, num_adcs);
> - if (ret)
> - return ret;
>
> return ret;
> }

We could even go one step further and do

return snd_soc_dapm_add_routes(dapm, ad183x_adc_routes, num_adcs);

But either is fine. Thanks for cleaning this up