Fix cppcheck error
cppcheck comments that this can be const. Unfortunately, this looks
like a false positive, where cppcheck cannot see through the
std::replace template.
Tested: This is in the set pid loop handler that doesn't have any good
tests with it. Code compiles, and only inspection is possible at this
time.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I21eaadcc37b2f3993e63b39d471cbf118d88119a
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 55c3949..7194eb0 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -938,37 +938,23 @@
}
output.emplace_back("Zones", std::move(zonesStr));
}
- if (inputs || outputs)
+
+ if (inputs)
{
- std::array<
- std::reference_wrapper<std::optional<std::vector<std::string>>>,
- 2>
- containers = {inputs, outputs};
- size_t index = 0;
- for (std::optional<std::vector<std::string>>& container :
- containers)
+ for (std::string& value : *inputs)
{
- if (!container)
- {
- index++;
- continue;
- }
- for (std::string& value : *container)
- {
- std::replace(value.begin(), value.end(), '_', ' ');
- }
- std::string key;
- if (index == 0)
- {
- key = "Inputs";
- }
- else
- {
- key = "Outputs";
- }
- output.emplace_back(key, *container);
- index++;
+ std::replace(value.begin(), value.end(), '_', ' ');
}
+ output.emplace_back("Inputs", *inputs);
+ }
+
+ if (outputs)
+ {
+ for (std::string& value : *outputs)
+ {
+ std::replace(value.begin(), value.end(), '_', ' ');
+ }
+ output.emplace_back("Outputs", *outputs);
}
if (setpointOffset)