Skip to contentSkip to conversation

ASoC: WM8804: Workaround GCC uninitialised variable warning

PATCH In review Dimitris Papastamos 2 participants 2 messages Oct 1, 2010 – Oct 2, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: WM8804: Workaround GCC uninitialised variable warning

GCC 4.4.0 does not seem capable of working out that the variable is never used unless it is initialised.

---
 sound/soc/codecs/wm8804.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
sound/soc/codecs/wm8804.c +8 -1
index 40e5067..e1fc722 100644
@@ -392,13 +392,20 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id,
 {
 	int ret;
 	struct snd_soc_codec *codec;
-	struct pll_div pll_div = { 0 };
+	struct pll_div pll_div;
 
 	codec = dai->codec;
 	if (freq_in && freq_out) {
 		ret = pll_factors(&pll_div, freq_out, freq_in);
 		if (ret)
 			return ret;
+	} else {
+		/*
+		 * Bodge GCC 4.4.0 uninitialised variable warning - it
+		 * doesn't seem capable of working out that we exit if
+		 * freq_in or freq_out is 0 before any of the uses.
+		 */
+		memset(&pll_div, 0, sizeof pll_div);
 	}
 
 	/* power down the PLL before reprogramming it */
Signature · 1 line
1.7.3.1
#1 lore raw
Quoted 24 lines · Dimitris Papastamos

GCC 4.4.0 does not seem capable of working out that the variable is never used unless it is initialised.

---
 sound/soc/codecs/wm8804.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
sound/soc/codecs/wm8804.c +1 -1
index 40e5067..e1fc722 100644
@@ -392,13 +392,20 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id,
 {
 	int ret;
 	struct snd_soc_codec *codec;
-	struct pll_div pll_div = { 0 };
+	struct pll_div pll_div;
 
 	codec = dai->codec;
 	if (freq_in && freq_out) {
 		ret = pll_factors(&pll_div, freq_out, freq_in);
 		if (ret)
 			return ret;

sound/soc/codecs/wm8804.c static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, · line 411

Quoted 10 lines
sound/soc/codecs/wm8804.c +7 -0
+	} else {
+		/*
+		 * Bodge GCC 4.4.0 uninitialised variable warning - it
+		 * doesn't seem capable of working out that we exit if
+		 * freq_in or freq_out is 0 before any of the uses.
+		 */
+		memset(&pll_div, 0, sizeof pll_div);
 	}
 
 	/* power down the PLL before reprogramming it */

Is it not possible to refactor your logic here to be more like wm8753_set_pll() rather than this ugly workaround ?

Liam