summaryrefslogtreecommitdiff
path: root/redfish-core/include/event_service_manager.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-03-15 20:44:42 +0300
committerEd Tanous <edtanous@google.com>2022-05-13 01:08:18 +0300
commit1476687deb1697d865b20458a0097c9ab5fd44e2 (patch)
tree6964ba82c382d03522f7a413a61ae1164b8e242e /redfish-core/include/event_service_manager.hpp
parent1656b296313d75b172dcdbe5f37ff1d1b54800dc (diff)
downloadbmcweb-1476687deb1697d865b20458a0097c9ab5fd44e2.tar.xz
Remove brace initialization of json objects
Brace initialization of json objects, while quite interesting from an academic sense, are very difficult for people to grok, and lead to inconsistencies. This patchset aims to remove a majority of them in lieu of operator[]. Interestingly, this saves about 1% of the binary size of bmcweb. This also has an added benefit that as a design pattern, we're never constructing a new object, then moving it into place, we're always adding to the existing object, which in the future _could_ make things like OEM schemas or properties easier, as there's no case where we're completely replacing the response object. Tested: Ran redfish service validator. No new failures. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iae409b0a40ddd3ae6112cb2d52c6f6ab388595fe
Diffstat (limited to 'redfish-core/include/event_service_manager.hpp')
-rw-r--r--redfish-core/include/event_service_manager.hpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 58bf25786f..4e50e4b829 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -253,14 +253,14 @@ inline int formatEventLogEntry(const std::string& logEntryID,
}
// Fill in the log entry with the gathered data
- logEntryJson = {{"EventId", logEntryID},
- {"EventType", "Event"},
- {"Severity", std::move(severity)},
- {"Message", std::move(msg)},
- {"MessageId", messageID},
- {"MessageArgs", messageArgs},
- {"EventTimestamp", std::move(timestamp)},
- {"Context", customText}};
+ logEntryJson["EventId"] = logEntryID;
+ logEntryJson["EventType"] = "Event";
+ logEntryJson["Severity"] = std::move(severity);
+ logEntryJson["Message"] = std::move(msg);
+ logEntryJson["MessageId"] = messageID;
+ logEntryJson["MessageArgs"] = messageArgs;
+ logEntryJson["EventTimestamp"] = std::move(timestamp);
+ logEntryJson["Context"] = customText;
return 0;
}
@@ -419,10 +419,11 @@ class Subscription : public persistent_data::UserSubscription
{"EventTimestamp", crow::utility::getDateTimeOffsetNow().first},
{"Context", customText}};
- nlohmann::json msg = {{"@odata.type", "#Event.v1_4_0.Event"},
- {"Id", std::to_string(eventSeqNum)},
- {"Name", "Event Log"},
- {"Events", logEntryArray}};
+ nlohmann::json msg;
+ msg["@odata.type"] = "#Event.v1_4_0.Event";
+ msg["Id"] = std::to_string(eventSeqNum);
+ msg["Name"] = "Event Log";
+ msg["Events"] = logEntryArray;
std::string strMsg =
msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
@@ -487,10 +488,11 @@ class Subscription : public persistent_data::UserSubscription
return;
}
- nlohmann::json msg = {{"@odata.type", "#Event.v1_4_0.Event"},
- {"Id", std::to_string(eventSeqNum)},
- {"Name", "Event Log"},
- {"Events", logEntryArray}};
+ nlohmann::json msg;
+ msg["@odata.type"] = "#Event.v1_4_0.Event";
+ msg["Id"] = std::to_string(eventSeqNum);
+ msg["Name"] = "Event Log";
+ msg["Events"] = logEntryArray;
std::string strMsg =
msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);