Skip to contentSkip to conversation

fix build waring: drivers/regulator/core.c: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized]

PATCH In review helight 2 participants 2 messages Nov 9, 2012 Voltage and current regulator framework

lore
Share & tools
lore

helight

author
#0 lore raw

PATCH 1/1 fix build waring: drivers/regulator/core.c: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized]

fix build waring on drivers/regulator/core.c
drivers/regulator/core.c: In function ‘regulator_get_bypass_regmap’:
drivers/regulator/core.c:2748:16: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized] drivers/regulator/core.c: In function ‘regulator_get_voltage_sel_regmap’:
drivers/regulator/core.c:2016:6: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized] drivers/regulator/core.c: In function ‘regulator_is_enabled_regmap’:
drivers/regulator/core.c:1786:14: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized]

Quoted 1 line

From c5b564ba10101961ffca9a67c6ddcc6216b99dce Mon Sep 17 00:00:00 2001

From: helight xu <[email protected]>
Date: Sat, 10 Nov 2012 01:11:14 +0800
Subject: [PATCH] fix build waring: drivers/regulator/core.c: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized]

---
 drivers/regulator/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/core.c +3 -3
index 5c4829c..7ad7174 100644
@@ -1776,8 +1776,8 @@ EXPORT_SYMBOL_GPL(regulator_disable_deferred);
  */
 int regulator_is_enabled_regmap(struct regulator_dev *rdev)
 {
-   unsigned int val;
    int ret;
+   unsigned int val = 0;
 
    ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
    if (ret != 0)
@@ -2006,8 +2006,8 @@ EXPORT_SYMBOL_GPL(regulator_is_supported_voltage);
  */
 int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev)
 {
-   unsigned int val;
    int ret;
+   unsigned int val = 0;
 
    ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val);
    if (ret != 0)
@@ -2738,8 +2738,8 @@ EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap);
  */
 int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable)
 {
-   unsigned int val;
    int ret;
+   unsigned int val = 0;
 
    ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val);
    if (ret != 0)
Signature · 1 line
1.7.10.4
#1 lore raw

drivers/regulator/core.c EXPORT_SYMBOL_GPL(regulator_disable_deferred); · line 1780

Quoted 3 lines · helight
drivers/regulator/core.c +1 -1
-   unsigned int val;
    int ret;
+   unsigned int val = 0;

This sort of change is really not at all helpful, we should be making sure that whatever path should be initialising the value but isn't does so, just initialising at declaration means that if the compiler has spotted a genuine error we won't fix it.