Fix -1 issue when fan collection size is 0.
When fan collection size is 0, the MinNumNeeded shown -1
(4294967295/0xffffffff) but not 0.
"Redundancy": [
{
"@odata.id": "/redfish/v1/Chassis/WC_Baseboard/Thermal#/Redundancy/0",
"@odata.type": "#Redundancy.v1_3_2.Redundancy",
"MemberId": "Tach",
"MinNumNeeded": 4294967295,
"Mode": "N+m",
"Name": "Tach",
"RedundancySet": [],
"Status": {
"Health": "OK",
"State": "Enabled"
}
}
Tested:
"MinNumNeeded" is 0 correctly.
https://bmc_ip/redfish/v1/Chassis/WC_Baseboard/Thermal
"Redundancy": [
{
"@odata.id": "/redfish/v1/Chassis/WC_Baseboard/Thermal#/Redundancy/0",
"@odata.type": "#Redundancy.v1_3_2.Redundancy",
"MemberId": "Tach",
"MinNumNeeded": 0,
"Mode": "N+m",
"Name": "Tach",
"RedundancySet": [],
"Status": {
"Health": "OK",
"State": "Enabled"
}
}
Change-Id: I8bf01dacd705e5309c161c5f04289d2df45ca583
Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 212a4a4..f12bbe0 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -1208,6 +1208,10 @@
}
}
+ size_t minNumNeeded =
+ collection->size() > 0
+ ? collection->size() - *allowedFailures
+ : 0;
nlohmann::json& jResp =
sensorsAsyncResp->res
.jsonValue["Redundancy"];
@@ -1220,8 +1224,7 @@
std::to_string(jResp.size())},
{"@odata.type",
"#Redundancy.v1_3_2.Redundancy"},
- {"MinNumNeeded",
- collection->size() - *allowedFailures},
+ {"MinNumNeeded", minNumNeeded},
{"MemberId", name},
{"Mode", "N+m"},
{"Name", name},