Skip to contentSkip to conversation

mfd: Silence uninitialized variable warning for wm8994-core

PATCH In review Axel Lin 3 participants 3 messages Apr 5, 2012 – Apr 16, 2012

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 mfd: Silence uninitialized variable warning for wm8994-core

Fix below build warning:
CC drivers/mfd/wm8994-core.o
drivers/mfd/wm8994-core.c: In function 'wm8994_i2c_probe':
drivers/mfd/wm8994-core.c:582:7: warning: 'patch_regs' may be used uninitialized in this function [-Wuninitialized] drivers/mfd/wm8994-core.c:393:14: note: 'patch_regs' was declared here

---
 drivers/mfd/wm8994-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/wm8994-core.c +1 -1
index 9d7ca1e..bd02202 100644
@@ -390,7 +390,7 @@ static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq)
 	struct regmap_config *regmap_config;
 	const struct reg_default *regmap_patch = NULL;
 	const char *devname;
-	int ret, i, patch_regs;
+	int ret, i, patch_regs = 0;
 	int pulls = 0;
 
 	dev_set_drvdata(wm8994->dev, wm8994);
Signature · 1 line
1.7.5.4
#1 lore raw

drivers/mfd/wm8994-core.c static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq) · line 393

Quoted 2 lines · Axel Lin
drivers/mfd/wm8994-core.c +1 -1
-	int ret, i, patch_regs;
+	int ret, i, patch_regs = 0;

This just unconditionally squashes any possible warnings from this which isn't great. If we're going to work around flow analysis bugs like this it's better to do it by doing something like adding an assignment in the paths that GCC isn't figuring out than by just squashing everything.

#2 lore raw
In reply to Axel Lin

Hi Axel,

Quoted 16 lines · Axel Lin

Fix below build warning:
CC drivers/mfd/wm8994-core.o
drivers/mfd/wm8994-core.c: In function 'wm8994_i2c_probe':
drivers/mfd/wm8994-core.c:582:7: warning: 'patch_regs' may be used uninitialized in this function [-Wuninitialized] drivers/mfd/wm8994-core.c:393:14: note: 'patch_regs' was declared here

---
 drivers/mfd/wm8994-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/wm8994-core.c +0 -0
index 9d7ca1e..bd02202 100644

drivers/mfd/wm8994-core.c static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq) · line 393

Quoted 5 lines
drivers/mfd/wm8994-core.c +1 -1
@@ -390,7 +390,7 @@ static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq)
 	struct regmap_config *regmap_config;
 	const struct reg_default *regmap_patch = NULL;
 	const char *devname;
-	int ret, i, patch_regs;
+	int ret, i, patch_regs = 0;

I'd agree with Mark here. I don't particularily like this kind of fix as it basically turns potentially useful gcc warnings off.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/