clang-tidy-21: fix cppcoreguidelines-pro-bounds-pointer-arithmetic
Fix various pro-bounds-pointer-arithmetic warnings that started being
reported with clang-tidy-21.
```
error: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic,-warnings-as-errors]
```
Forked this change from [1]
References:
[1] https://gerrit.openbmc.org/c/openbmc/entity-manager/+/84049
Tested: Inspection only.
Change-Id: I535802825e68d7f5fe01ed2428d127f7a18ab4f8
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/fru_device/fru_utils.cpp b/src/fru_device/fru_utils.cpp
index 13e619f..14ec8c1 100644
--- a/src/fru_device/fru_utils.cpp
+++ b/src/fru_device/fru_utils.cpp
@@ -781,7 +781,8 @@
}
std::vector<uint8_t> device;
- device.insert(device.end(), blockData.begin(), blockData.begin() + 8);
+ device.insert(device.end(), blockData.begin(),
+ std::next(blockData.begin(), 8));
bool hasMultiRecords = false;
size_t fruLength = fruBlockSize; // At least FRU header is present
@@ -889,7 +890,7 @@
}
device.insert(device.end(), blockData.begin(),
- blockData.begin() + requestLength);
+ std::next(blockData.begin(), requestLength));
readOffset += requestLength;
fruLength -= std::min(requestLength, fruLength);