[PATCH 05/10] ASoC: wm8958-dsp2: rename local 'control' arrays

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Thu Mar 11 01:43:27 CET 2021


cppcheck complains about shadowed variables:

sound/soc/codecs/wm8958-dsp2.c:926:27: style: Local variable 'control'
shadows outer variable [shadowVariable]

  struct snd_kcontrol_new control[] = {
                          ^
sound/soc/codecs/wm8958-dsp2.c:900:17: note: Shadowed declaration
 struct wm8994 *control = wm8994->wm8994;
                ^
sound/soc/codecs/wm8958-dsp2.c:926:27: note: Shadow variable
  struct snd_kcontrol_new control[] = {
                          ^
sound/soc/codecs/wm8958-dsp2.c:952:27: style: Local variable 'control'
shadows outer variable [shadowVariable]
  struct snd_kcontrol_new control[] = {
                          ^
sound/soc/codecs/wm8958-dsp2.c:900:17: note: Shadowed declaration
 struct wm8994 *control = wm8994->wm8994;
                ^
sound/soc/codecs/wm8958-dsp2.c:952:27: note: Shadow variable
  struct snd_kcontrol_new control[] = {
                          ^
sound/soc/codecs/wm8958-dsp2.c:978:27: style: Local variable 'control'
shadows outer variable [shadowVariable]
  struct snd_kcontrol_new control[] = {
                          ^
sound/soc/codecs/wm8958-dsp2.c:900:17: note: Shadowed declaration
 struct wm8994 *control = wm8994->wm8994;
                ^
sound/soc/codecs/wm8958-dsp2.c:978:27: note: Shadow variable
  struct snd_kcontrol_new control[] = {
                          ^
sound/soc/codecs/wm8958-dsp2.c:1006:27: style: Local variable
'control' shadows outer variable [shadowVariable]
  struct snd_kcontrol_new control[] = {
                          ^
sound/soc/codecs/wm8958-dsp2.c:900:17: note: Shadowed declaration
 struct wm8994 *control = wm8994->wm8994;
                ^
sound/soc/codecs/wm8958-dsp2.c:1006:27: note: Shadow variable
  struct snd_kcontrol_new control[] = {
                          ^

fix by adding a prefix related to each control.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
---
 sound/soc/codecs/wm8958-dsp2.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index 3bce9a14f0f3..536339e43dc7 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -923,7 +923,7 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
 				component, wm8958_enh_eq_loaded);
 
 	if (pdata->num_mbc_cfgs) {
-		struct snd_kcontrol_new control[] = {
+		struct snd_kcontrol_new mbc_control[] = {
 			SOC_ENUM_EXT("MBC Mode", wm8994->mbc_enum,
 				     wm8958_get_mbc_enum, wm8958_put_mbc_enum),
 		};
@@ -942,14 +942,14 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
 		wm8994->mbc_enum.texts = wm8994->mbc_texts;
 
 		ret = snd_soc_add_component_controls(wm8994->hubs.component,
-						 control, 1);
+						 mbc_control, 1);
 		if (ret != 0)
 			dev_err(wm8994->hubs.component->dev,
 				"Failed to add MBC mode controls: %d\n", ret);
 	}
 
 	if (pdata->num_vss_cfgs) {
-		struct snd_kcontrol_new control[] = {
+		struct snd_kcontrol_new vss_control[] = {
 			SOC_ENUM_EXT("VSS Mode", wm8994->vss_enum,
 				     wm8958_get_vss_enum, wm8958_put_vss_enum),
 		};
@@ -968,14 +968,14 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
 		wm8994->vss_enum.texts = wm8994->vss_texts;
 
 		ret = snd_soc_add_component_controls(wm8994->hubs.component,
-						 control, 1);
+						 vss_control, 1);
 		if (ret != 0)
 			dev_err(wm8994->hubs.component->dev,
 				"Failed to add VSS mode controls: %d\n", ret);
 	}
 
 	if (pdata->num_vss_hpf_cfgs) {
-		struct snd_kcontrol_new control[] = {
+		struct snd_kcontrol_new hpf_control[] = {
 			SOC_ENUM_EXT("VSS HPF Mode", wm8994->vss_hpf_enum,
 				     wm8958_get_vss_hpf_enum,
 				     wm8958_put_vss_hpf_enum),
@@ -995,7 +995,7 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
 		wm8994->vss_hpf_enum.texts = wm8994->vss_hpf_texts;
 
 		ret = snd_soc_add_component_controls(wm8994->hubs.component,
-						 control, 1);
+						 hpf_control, 1);
 		if (ret != 0)
 			dev_err(wm8994->hubs.component->dev,
 				"Failed to add VSS HPFmode controls: %d\n",
@@ -1003,7 +1003,7 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
 	}
 
 	if (pdata->num_enh_eq_cfgs) {
-		struct snd_kcontrol_new control[] = {
+		struct snd_kcontrol_new eq_control[] = {
 			SOC_ENUM_EXT("Enhanced EQ Mode", wm8994->enh_eq_enum,
 				     wm8958_get_enh_eq_enum,
 				     wm8958_put_enh_eq_enum),
@@ -1023,7 +1023,7 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
 		wm8994->enh_eq_enum.texts = wm8994->enh_eq_texts;
 
 		ret = snd_soc_add_component_controls(wm8994->hubs.component,
-						 control, 1);
+						 eq_control, 1);
 		if (ret != 0)
 			dev_err(wm8994->hubs.component->dev,
 				"Failed to add enhanced EQ controls: %d\n",
-- 
2.25.1



More information about the Alsa-devel mailing list