Strip extra spaces from fru
Trailing spaces were discovered in the FRU EEPROM of some SSDs, which
should not originally appear in the device. Strip the trailing spaces
in case that one gets the properties about FRU with unnecessary spaces.
Tested:
before the CL added:
curl http://localhost/redfish/v1/Chassis/SSD_NVMe_2/ | \
grep -E "PartNumber|SerialNumber"
% Total % Received % Xferd Average Speed Time Time Time
Dload Upload Total Spent Left
100 1661 100 1661 0 0 104k 0 --:--:-- --:--:-- --:--:--
"PartNumber": "MZWLO7T6HBLA-01AGG ",
"SerialNumber": "S7BVNE0W900253 ",
After after CL added :
curl http://localhost/redfish/v1/Chassis/SSD_NVMe_2/ | \
grep -E "PartNumber|SerialNumber"
% Total % Received % Xferd Average Speed Time Time Time
Dload Upload Total Spent Left
100 1661 100 1661 0 0 98739 0 --:--:-- --:--:-- --:--:--
"PartNumber": "MZWLO7T6HBLA-01AGG",
"SerialNumber": "S7BVNE0W900253"
Change-Id: I4faf5b4fa62f2330ed0d12f41b552af41ce7dd9a
Signed-off-by: Brian Chiang <chiang.brian@inventec.com>
diff --git a/src/fru_utils.cpp b/src/fru_utils.cpp
index f39bbac..c4b46cf 100644
--- a/src/fru_utils.cpp
+++ b/src/fru_utils.cpp
@@ -525,9 +525,11 @@
if (state == DecodeState::ok)
{
- // Strip non null characters from the end
+ // Strip non null characters and trailing spaces from the end
value.erase(std::find_if(value.rbegin(), value.rend(),
- [](char ch) { return ch != 0; })
+ [](char ch) {
+ return ((ch != 0) && (ch != ' '));
+ })
.base(),
value.end());