diff mbox series

[v2,4/6] ASoC: samsung: smdk_wm8994: add missing return

Message ID 20210222213306.22654-5-pierre-louis.bossart@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series ASoC: samsung: remove cppcheck warnings | expand

Commit Message

Pierre-Louis Bossart Feb. 22, 2021, 9:33 p.m. UTC
cppcheck warning:

sound/soc/samsung/smdk_wm8994.c:179:6: style: Variable 'ret' is
reassigned a value before the old one has been
used. [redundantAssignment]
 ret = devm_snd_soc_register_card(&pdev->dev, card);
     ^
sound/soc/samsung/smdk_wm8994.c:166:8: note: ret is assigned
   ret = -EINVAL;
       ^
sound/soc/samsung/smdk_wm8994.c:179:6: note: ret is overwritten
 ret = devm_snd_soc_register_card(&pdev->dev, card);
     ^

The initial authors bothered to set ret to -EINVAL and throw a
dev_err() message, so it looks like there is a missing return to avoid
continuing if the property is missing.

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/samsung/smdk_wm8994.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Sylwester Nawrocki Feb. 23, 2021, 11:08 a.m. UTC | #1
On 22.02.2021 22:33, Pierre-Louis Bossart wrote:

> The initial authors bothered to set ret to -EINVAL and throw a
> dev_err() message, so it looks like there is a missing return to avoid
> continuing if the property is missing.
> 
> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

> ---
>  sound/soc/samsung/smdk_wm8994.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c
> index 681b244d5312..39a7a449f554 100644
> --- a/sound/soc/samsung/smdk_wm8994.c
> +++ b/sound/soc/samsung/smdk_wm8994.c
> @@ -164,6 +164,7 @@ static int smdk_audio_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev,
>  			   "Property 'samsung,i2s-controller' missing or invalid\n");

>  			ret = -EINVAL;
> +			return ret;

I think it would be better to just make it "return -EINVAL;"
diff mbox series

Patch

diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c
index 681b244d5312..39a7a449f554 100644
--- a/sound/soc/samsung/smdk_wm8994.c
+++ b/sound/soc/samsung/smdk_wm8994.c
@@ -164,6 +164,7 @@  static int smdk_audio_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 			   "Property 'samsung,i2s-controller' missing or invalid\n");
 			ret = -EINVAL;
+			return ret;
 		}
 
 		smdk_dai[0].platforms->name = NULL;