fru-device: use off_t/size_t for FRU IO offsets & lengths
While the 8-bit and 16-bit types that had been used for these were
adequate for the small devices typically used for most FRU EEPROMs, some
do get within striking distance of the limits of 16-bit types, and we
might as well use the more "natural" types that are intended for these
sorts of parameters, which avoid the risk of range problems and signal
intent more clearly & explicitly.
Tested: on an ASRock Rack romed8hm3, fru-device successfully recognizes
and parses the baseboard FRU EEPROM as it did prior to this patch.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I38251fec2857923356d324e01af77795186560eb
diff --git a/test/test_fru-utils.cpp b/test/test_fru-utils.cpp
index f37da0e..60b71e0 100644
--- a/test/test_fru-utils.cpp
+++ b/test/test_fru-utils.cpp
@@ -147,10 +147,10 @@
int64_t getDataTempl(const std::vector<uint8_t>& data,
[[maybe_unused]] int flag, [[maybe_unused]] int file,
- [[maybe_unused]] uint16_t address, uint16_t offset,
- uint8_t length, uint8_t* outBuf)
+ [[maybe_unused]] uint16_t address, off_t offset,
+ size_t length, uint8_t* outBuf)
{
- if (offset >= data.size())
+ if (offset >= static_cast<off_t>(data.size()))
{
return 0;
}
@@ -168,7 +168,7 @@
TEST(FindFRUHeaderTest, InvalidHeader)
{
const std::vector<uint8_t> data = {255, 16};
- uint16_t offset = 0;
+ off_t offset = 0;
std::array<uint8_t, I2C_SMBUS_BLOCK_MAX> blockData;
auto getData = [&data](auto fl, auto fi, auto a, auto o, auto l, auto* b) {
return getDataTempl(data, fl, fi, a, o, l, b);
@@ -180,7 +180,7 @@
TEST(FindFRUHeaderTest, NoData)
{
const std::vector<uint8_t> data = {};
- uint16_t offset = 0;
+ off_t offset = 0;
std::array<uint8_t, I2C_SMBUS_BLOCK_MAX> blockData;
auto getData = [&data](auto fl, auto fi, auto a, auto o, auto l, auto* b) {
return getDataTempl(data, fl, fi, a, o, l, b);
@@ -193,7 +193,7 @@
{
const std::vector<uint8_t> data = {0x01, 0x00, 0x01, 0x02,
0x03, 0x04, 0x00, 0xf5};
- uint16_t offset = 0;
+ off_t offset = 0;
std::array<uint8_t, I2C_SMBUS_BLOCK_MAX> blockData;
auto getData = [&data](auto fl, auto fi, auto a, auto o, auto l, auto* b) {
return getDataTempl(data, fl, fi, a, o, l, b);
@@ -207,7 +207,7 @@
{
std::vector<uint8_t> data = {'$', 'T', 'Y', 'A', 'N', '$', 0, 0};
data.resize(0x6000 + I2C_SMBUS_BLOCK_MAX);
- uint16_t offset = 0;
+ off_t offset = 0;
std::array<uint8_t, I2C_SMBUS_BLOCK_MAX> blockData;
auto getData = [&data](auto fl, auto fi, auto a, auto o, auto l, auto* b) {
return getDataTempl(data, fl, fi, a, o, l, b);
@@ -219,7 +219,7 @@
TEST(FindFRUHeaderTest, TyanNoData)
{
const std::vector<uint8_t> data = {'$', 'T', 'Y', 'A', 'N', '$', 0, 0};
- uint16_t offset = 0;
+ off_t offset = 0;
std::array<uint8_t, I2C_SMBUS_BLOCK_MAX> blockData;
auto getData = [&data](auto fl, auto fi, auto a, auto o, auto l, auto* b) {
return getDataTempl(data, fl, fi, a, o, l, b);
@@ -236,7 +236,7 @@
0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x00, 0xf5};
copy(fruHeader.begin(), fruHeader.end(), back_inserter(data));
- uint16_t offset = 0;
+ off_t offset = 0;
std::array<uint8_t, I2C_SMBUS_BLOCK_MAX> blockData;
auto getData = [&data](auto fl, auto fi, auto a, auto o, auto l, auto* b) {
return getDataTempl(data, fl, fi, a, o, l, b);