Remove the last instances of json pattern
In the past, we've tried to erradicate the use of
nlohmann::json(initiatlizer_list<...>) because it bloats binary sizes,
as every type is given a new nlohmann constructor.
This commit hunts down the last few places where we call this. There is
still 2 remaining in openbmc_dbus_rest after this, but those are variant
accesses that are difficult to triage, and considering it's a less used
api, they're left as is.
Tested: WIP
Change-Id: Iaac24584bb78bb238da69010b511c1d598bd38bc
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 6b758e7..2687ecf 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -46,6 +46,7 @@
#include <memory>
#include <string>
#include <string_view>
+#include <utility>
#include <variant>
#include <vector>
@@ -942,11 +943,19 @@
BMCWEB_LOG_DEBUG("Boot mode: {}", bootModeStr);
+ nlohmann::json::array_t allowed;
+ allowed.emplace_back("None");
+ allowed.emplace_back("Pxe");
+ allowed.emplace_back("Hdd");
+ allowed.emplace_back("Cd");
+ allowed.emplace_back("Diags");
+ allowed.emplace_back("BiosSetup");
+ allowed.emplace_back("Usb");
+
asyncResp->res
.jsonValue["Boot"]
- ["BootSourceOverrideTarget@Redfish.AllowableValues"] = {
- "None", "Pxe", "Hdd", "Cd", "Diags", "BiosSetup", "Usb"};
-
+ ["BootSourceOverrideTarget@Redfish.AllowableValues"] =
+ std::move(allowed);
if (bootModeStr !=
"xyz.openbmc_project.Control.Boot.Mode.Modes.Regular")
{
@@ -1245,9 +1254,12 @@
// "AutomaticRetryConfig" can be 3 values, Disabled, RetryAlways,
// and RetryAttempts. OpenBMC only supports Disabled and
// RetryAttempts.
+ nlohmann::json::array_t allowed;
+ allowed.emplace_back("Disabled");
+ allowed.emplace_back("RetryAttempts");
asyncResp->res
.jsonValue["Boot"]["AutomaticRetryConfig@Redfish.AllowableValues"] =
- {"Disabled", "RetryAttempts"};
+ std::move(allowed);
});
}