From ddf3564e48bcee32dff1eff7a985a084be529615 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Wed, 27 Mar 2024 14:12:21 -0700 Subject: Enable readability check readability-avoid-nested-conditional-operator With one exception, we already pass this check. Update the log services code to make it pass, and update it to use the generated enums. Tested: Code inspection only. Change-Id: Ic80a7382beb0f541de4916d7b51e42ed5d5dc542 Signed-off-by: Ed Tanous --- .clang-tidy | 1 + redfish-core/lib/log_services.hpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 7cb9ecdd8e..ca103f34cf 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -305,6 +305,7 @@ performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, performance-unnecessary-value-param, readability-avoid-const-params-in-decls, +readability-avoid-nested-conditional-operator, readability-braces-around-statements, readability-const-return-type, readability-container-contains, diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 24f0251ee1..4ea01e3531 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -2594,9 +2594,17 @@ static int bmcJournalLogEntryJson["Id"] = bmcJournalLogEntryID; bmcJournalLogEntryJson["Message"] = std::move(message); bmcJournalLogEntryJson["EntryType"] = "Oem"; - bmcJournalLogEntryJson["Severity"] = severity <= 2 ? "Critical" - : severity <= 4 ? "Warning" - : "OK"; + log_entry::EventSeverity severityEnum = log_entry::EventSeverity::OK; + if (severity <= 2) + { + severityEnum = log_entry::EventSeverity::Critical; + } + else if (severity <= 4) + { + severityEnum = log_entry::EventSeverity::Warning; + } + + bmcJournalLogEntryJson["Severity"] = severityEnum; bmcJournalLogEntryJson["OemRecordFormat"] = "BMC Journal Entry"; bmcJournalLogEntryJson["Created"] = std::move(entryTimeStr); return 0; -- cgit v1.2.3