fix error checking from i2c read return
Correct data type to capture i2c read return so error can be
detected correctly.
Tested:
Build and run the new code. No issues observed.
Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
Change-Id: Ie6bf9480f3bc43945adb39adb0d781df794e639e
diff --git a/libpfr/inc/file.hpp b/libpfr/inc/file.hpp
index 3f48666..c333c34 100644
--- a/libpfr/inc/file.hpp
+++ b/libpfr/inc/file.hpp
@@ -82,13 +82,13 @@
*/
uint8_t i2cReadByteData(const uint8_t& offset)
{
- uint8_t value = i2c_smbus_read_byte_data(fd, offset);
+ int value = i2c_smbus_read_byte_data(fd, offset);
if (value < 0)
{
throw std::runtime_error("i2c_smbus_read_byte_data() failed");
}
- return value;
+ return static_cast<uint8_t>(value);
}
/** @brief Reads the block of data from I2C dev