[PATCH 10/10] ASoC: lpass-wsa-macro: add missing test

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Thu Feb 18 23:29:16 CET 2021


cppcheck warning:

sound/soc/codecs/lpass-wsa-macro.c:958:6: style: Variable 'ret' is
reassigned a value before the old one has been
used. [redundantAssignment]
 ret = wsa_macro_set_prim_interpolator_rate(dai, (u8) rate_val, sample_rate);
     ^
sound/soc/codecs/lpass-wsa-macro.c:946:6: note: ret is assigned
 ret = wsa_macro_set_mix_interpolator_rate(dai, (u8) rate_val, sample_rate);
     ^
sound/soc/codecs/lpass-wsa-macro.c:958:6: note: ret is overwritten
 ret = wsa_macro_set_prim_interpolator_rate(dai, (u8) rate_val, sample_rate);
     ^

set_mix_interpolator_rate can return -EINVAL, add a test and bail on error.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
---
 sound/soc/codecs/lpass-wsa-macro.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index 5ebcd935ba89..0be5d25e2a29 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -944,6 +944,8 @@ static int wsa_macro_set_interpolator_rate(struct snd_soc_dai *dai,
 		goto prim_rate;
 
 	ret = wsa_macro_set_mix_interpolator_rate(dai, (u8) rate_val, sample_rate);
+	if (ret < 0)
+		return ret;
 prim_rate:
 	/* set primary path sample rate */
 	for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
-- 
2.25.1



More information about the Alsa-devel mailing list