mbox series

[0/2] ASoC: cppcheck fixups

Message ID 875ybuqjcg.wl-kuninori.morimoto.gx@renesas.com
Headers show
Series ASoC: cppcheck fixups | expand

Message

Kuninori Morimoto Feb. 22, 2023, 6:56 a.m. UTC
Hi Mark
Cc Takashi

This patch-set fixes the issues which is reported by cppcheck.

 sound/pci/asihpi/hpi6205.c   | 2 +-
 sound/pci/hda/patch_ca0132.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

It still reports about sound/pci/ice1712/wm8766.c (A)
that there is a case that "val2" might be used with uninitialized.
But I'm not sure what is the good solution for it.
So, I can do is only

Reported-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

	static int snd_wm8766_ctl_get(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
	{
		struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
		int n = kcontrol->private_value;
		u16 val1, val2;

		if (wm->ctl[n].get)
			wm->ctl[n].get(wm, &val1, &val2);
		else {
			val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1;
			val1 >>= __ffs(wm->ctl[n].mask1);
			if (wm->ctl[n].flags & WM8766_FLAG_STEREO) {
				val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2;
				val2 >>= __ffs(wm->ctl[n].mask2);
				if (wm->ctl[n].flags & WM8766_FLAG_VOL_UPDATE)
					val2 &= ~WM8766_VOL_UPDATE;
			}
		}
		if (wm->ctl[n].flags & WM8766_FLAG_INVERT) {
			val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min);
			if (wm->ctl[n].flags & WM8766_FLAG_STEREO)
(A)				val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min);
		}                                        ^^^^
		ucontrol->value.integer.value[0] = val1;
		if (wm->ctl[n].flags & WM8766_FLAG_STEREO)
			ucontrol->value.integer.value[1] = val2;

		return 0;
	}


--
2.25.1