RE: [PATCH][next] ASoC: rt-sdw-common: Fix bit-wise or'ing of values into uninitialized variable ret

From: Jack Yu
Date: Tue Oct 08 2024 - 22:17:07 EST




> -----Original Message-----
> From: Mark Brown <broonie@xxxxxxxxxx>
> Sent: Wednesday, October 9, 2024 1:04 AM
> To: Colin Ian King <colin.i.king@xxxxxxxxx>
> Cc: Oder Chiou <oder_chiou@xxxxxxxxxxx>; Liam Girdwood
> <lgirdwood@xxxxxxxxx>; Jaroslav Kysela <perex@xxxxxxxx>; Takashi Iwai
> <tiwai@xxxxxxxx>; Jack Yu <jack.yu@xxxxxxxxxxx>;
> linux-sound@xxxxxxxxxxxxxxx; kernel-janitors@xxxxxxxxxxxxxxx;
> linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH][next] ASoC: rt-sdw-common: Fix bit-wise or'ing of values
> into uninitialized variable ret
>
> On Tue, Oct 08, 2024 at 05:47:07PM +0100, Colin Ian King wrote:
> > There are a handful of bit-wise or'ing of values into the
> > uninitialized variable ret resulting in garbage results. Fix this by
> > ininitializing ret to zero.
>
> I'm very disappinted in the compiler for not noticing this :(

I'm sorry for such mistake. I've sent a patch to fix this yesterday, please refer attachment.
--- Begin Message --- Fix issue of warning messages caused by some variables.

Signed-off-by: Jack Yu <jack.yu@xxxxxxxxxxx>
---
sound/soc/codecs/rt-sdw-common.c | 2 +-
sound/soc/codecs/rt721-sdca.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/rt-sdw-common.c b/sound/soc/codecs/rt-sdw-common.c
index 9ed0e9855699..a422da6cf702 100644
--- a/sound/soc/codecs/rt-sdw-common.c
+++ b/sound/soc/codecs/rt-sdw-common.c
@@ -108,7 +108,7 @@ EXPORT_SYMBOL_GPL(rt_sdca_index_update_bits);
int rt_sdca_btn_type(unsigned char *buffer)
{
u8 btn_type = 0;
- int ret;
+ int ret = 0;

btn_type |= buffer[0] & 0xf;
btn_type |= (buffer[0] >> 4) & 0xf;
diff --git a/sound/soc/codecs/rt721-sdca.c b/sound/soc/codecs/rt721-sdca.c
index 36056cb7a3ca..201cb667c8c1 100644
--- a/sound/soc/codecs/rt721-sdca.c
+++ b/sound/soc/codecs/rt721-sdca.c
@@ -30,7 +30,7 @@ static void rt721_sdca_jack_detect_handler(struct work_struct *work)
{
struct rt721_sdca_priv *rt721 =
container_of(work, struct rt721_sdca_priv, jack_detect_work.work);
- int btn_type = 0, ret;
+ int btn_type = 0;

if (!rt721->hs_jack)
return;
@@ -42,7 +42,7 @@ static void rt721_sdca_jack_detect_handler(struct work_struct *work)
if (rt721->scp_sdca_stat1 & SDW_SCP_SDCA_INT_SDCA_6) {
rt721->jack_type = rt_sdca_headset_detect(rt721->regmap,
RT721_SDCA_ENT_GE49);
- if (ret < 0)
+ if (rt721->jack_type < 0)
return;
}

--
2.34.1


--- End Message ---