fru-device: Fix -Werror=sign-compare
Fix a warning under GCC10. There doesn't seem to be any need for this
length holding variable to be signed.
Fixes: 2f0de17eddbc
Change-Id: If19849acd975b49699218296742c8a369e4b8af2
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index b2072e6..44ca05d 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -171,7 +171,7 @@
device.insert(device.end(), blockData.begin(), blockData.begin() + 8);
bool hasMultiRecords = false;
- ssize_t fruLength = fruBlockSize; // At least FRU header is present
+ size_t fruLength = fruBlockSize; // At least FRU header is present
for (fruAreas area = fruAreas::fruAreaInternal;
area <= fruAreas::fruAreaMultirecord; ++area)
{
@@ -245,14 +245,14 @@
}
// You already copied these first 8 bytes (the ipmi fru header size)
- fruLength -= fruBlockSize;
+ fruLength -= std::min(fruBlockSize, fruLength);
int readOffset = fruBlockSize;
while (fruLength > 0)
{
- int requestLength =
- std::min(I2C_SMBUS_BLOCK_MAX, static_cast<int>(fruLength));
+ size_t requestLength =
+ std::min(static_cast<size_t>(I2C_SMBUS_BLOCK_MAX), fruLength);
if (readBlock(flag, file, address, static_cast<uint16_t>(readOffset),
static_cast<uint8_t>(requestLength),
@@ -266,7 +266,7 @@
blockData.begin() + requestLength);
readOffset += requestLength;
- fruLength -= requestLength;
+ fruLength -= std::min(requestLength, fruLength);
}
return device;