i2c: Initialize variable ret
The varialbe `ret` in some functions is not initialized and cause the
build warning and treated as error:
error: 'ret' may be used uninitialized in this function
[-Werror=maybe-uninitialized]
Fixes openbmc/phosphor-power#3.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Ica6b1af434736f6fd96a1bbb9e511bf1c8fb1d7a
diff --git a/tools/i2c/i2c.cpp b/tools/i2c/i2c.cpp
index 4715c6e..7a0bbf4 100644
--- a/tools/i2c/i2c.cpp
+++ b/tools/i2c/i2c.cpp
@@ -200,7 +200,7 @@
void I2CDevice::read(uint8_t addr, uint8_t& size, uint8_t* data, Mode mode)
{
checkIsOpen();
- int ret;
+ int ret = -1;
switch (mode)
{
case Mode::SMBUS:
@@ -261,7 +261,7 @@
Mode mode)
{
checkIsOpen();
- int ret;
+ int ret = -1;
switch (mode)
{
case Mode::SMBUS: