Skip to contentSkip to conversation

mfd: wm8994: add missing variable initialization

PATCH In review Jingoo Han 3 participants 5 messages Feb 19, 2013 – Apr 8, 2013

Subsystems (2)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/1 mfd: wm8994: add missing variable initialization

Fixed build warning as below:

drivers/mfd/wm8994-core.c: In function 'wm8994_i2c_probe':
drivers/mfd/wm8994-core.c:595:7: warning: 'patch_regs' may be used uninitialized in this function [-Wuninitialized] drivers/mfd/wm8994-core.c:408: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 803e93f..97e929e 100644
@@ -405,7 +405,7 @@ static 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;
 
 	if (dev_get_platdata(wm8994->dev)) {
Signature · 1 line
1.7.2.5
#1 lore raw

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

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

As with all such changes you really need to explain why it's safe to just blindly initialise to this particular value and why this isn't just masking a real issue in the code. Initialising with a random value will fix the warning but that might just be turning off the compiler's checks.

author
#2 lore raw

PATCH v2 1/1 mfd: wm8994: silence bogus warning in wm8994_device_init()

'patch_regs' cannot be used uninitialized in wm8994_device_init(), because 'patch_regs' was already guarded by 'regmap_patch'. Thus, that's a bogus warning.

Without this patch, the build warning happens as below:

drivers/mfd/wm8994-core.c: In function 'wm8994_i2c_probe':
drivers/mfd/wm8994-core.c:595:7: warning: 'patch_regs' may be used uninitialized in this function [-Wuninitialized] drivers/mfd/wm8994-core.c:408: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 803e93f..97e929e 100644
@@ -405,7 +405,7 @@ static 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;
 
 	if (dev_get_platdata(wm8994->dev)) {
Signature · 1 line
1.7.2.5
Acked-by on v2 1/1
#3 lore raw

Re: [PATCH v2] mfd: wm8994: silence bogus warning in wm8994_device_init()

Quoted 3 lines · Jingoo Han

'patch_regs' cannot be used uninitialized in wm8994_device_init(), because 'patch_regs' was already guarded by 'regmap_patch'. Thus, that's a bogus warning.

Applied
#4 lore raw

Re: [PATCH v2] mfd: wm8994: silence bogus warning in wm8994_device_init()

In reply to Jingoo Han

Hi Jingoo,

Quoted 6 lines · Jingoo Han

'patch_regs' cannot be used uninitialized in wm8994_device_init(), because 'patch_regs' was already guarded by 'regmap_patch'. Thus, that's a bogus warning.

Without this patch, the build warning happens as below:

Quoted 8 lines

drivers/mfd/wm8994-core.c: In function 'wm8994_i2c_probe':
drivers/mfd/wm8994-core.c:595:7: warning: 'patch_regs' may be used uninitialized in this function [-Wuninitialized] drivers/mfd/wm8994-core.c:408:14: note: 'patch_regs' was declared here

---
 drivers/mfd/wm8994-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Cheers,
Samuel.

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