[PATCH] i2c: core: Fix compiler warning in i2c_generic_scl_recovery

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The compiler is not smart enough to figure out that ret will always
be assiged a value in the while loop. Explicitly init ret, fixing:

drivers/i2c/i2c-core-base.c: In function ‘i2c_generic_scl_recovery’:
drivers/i2c/i2c-core-base.c:235:5: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  235 |  if (ret == -EOPNOTSUPP)
      |     ^

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
 drivers/i2c/i2c-core-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 38af18645133..c480ca385ffb 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -185,7 +185,7 @@ static int i2c_generic_bus_free(struct i2c_adapter *adap)
 int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 {
 	struct i2c_bus_recovery_info *bri = adap->bus_recovery_info;
-	int i = 0, scl = 1, ret;
+	int i = 0, scl = 1, ret = 0;
 
 	if (bri->prepare_recovery)
 		bri->prepare_recovery(adap);
-- 
2.21.0




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux