diff options
author | Shantappa Teekappanavar <shantappa.teekappanavar@ibm.com> | 2022-11-03 21:37:24 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-11-28 20:59:54 +0300 |
commit | 043360d02f5b5d8baaeb5e6b0caacc7521c0f93d (patch) | |
tree | ab21fb84601d1f3840773fffb5f5275437469d42 | |
parent | 5b3785464cb8a43dc6ab763789bb722bdc634ebc (diff) | |
download | bmcweb-043360d02f5b5d8baaeb5e6b0caacc7521c0f93d.tar.xz |
Populate cable properties if length is NaN
Cable Length property value is NaN by default. The current
implementation ignores processing other remaining Cable properties
if the length is NaN. Per Ed's comment here we need to
ignore if length is NaN and continue to process remaining properties:
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/50265/4..7/redfish-core\
/lib/cable.hpp#b51
Testing:
1. Validator test not done, assumed it is OK since it is a minor change
in the code logic.
2. curl testing:
$ curl -k https://user:password@host:18080/redfish/v1/Cables/dp0_cable1
{
"@odata.id": "/redfish/v1/Cables/dp0_cable1",
"@odata.type": "#Cable.v1_0_0.Cable",
"CableType": "",
"Id": "dp0_cable1",
"Name": "Cable"
}
Signed-off-by: Shantappa Teekappanavar <shantappa.teekappanavar@ibm.com>
Change-Id: If73828484d91bbf2eee45a31973c825bab008ba4
-rw-r--r-- | redfish-core/lib/cable.hpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp index 89f41e287b..6bc7fbaed7 100644 --- a/redfish-core/lib/cable.hpp +++ b/redfish-core/lib/cable.hpp @@ -48,15 +48,17 @@ inline void { if (!std::isfinite(*length)) { - if (std::isnan(*length)) + // Cable length is NaN by default, do not throw an error + if (!std::isnan(*length)) { + messages::internalError(resp); return; } - messages::internalError(resp); - return; } - - resp.jsonValue["LengthMeters"] = *length; + else + { + resp.jsonValue["LengthMeters"] = *length; + } } } |