clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: Id77d01d036ba05e52cdda0e6c6fbc47842e9baf8
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/service/src/mainapp.cpp b/service/src/mainapp.cpp
index b913e33..f7f8603 100644
--- a/service/src/mainapp.cpp
+++ b/service/src/mainapp.cpp
@@ -212,8 +212,8 @@
return;
}
- std::string errorStr = it->second.second + "(MinorCode:0x" +
- toHexString(minorErrorCode) + ")";
+ std::string errorStr =
+ it->second.second + "(MinorCode:0x" + toHexString(minorErrorCode) + ")";
std::string msgId = "OpenBMC.0.1." + it->second.first;
sd_journal_send(
"MESSAGE=%s", "Platform firmware resiliency error occurred.",
@@ -225,19 +225,19 @@
handleLastCountChange(std::shared_ptr<sdbusplus::asio::connection> conn,
std::string eventName, uint8_t currentCount)
{
- sdbusplus::asio::setProperty(*conn, "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/pfr/last_events",
- "xyz.openbmc_project.PFR.LastEvents",
- eventName, currentCount,
- [](boost::system::error_code ec) {
- if (ec)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "PFR: Unable to update currentCount",
- phosphor::logging::entry("MSG=%s", ec.message().c_str()));
- return;
- }
- });
+ sdbusplus::asio::setProperty(
+ *conn, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/pfr/last_events",
+ "xyz.openbmc_project.PFR.LastEvents", eventName, currentCount,
+ [](boost::system::error_code ec) {
+ if (ec)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "PFR: Unable to update currentCount",
+ phosphor::logging::entry("MSG=%s", ec.message().c_str()));
+ return;
+ }
+ });
return;
}
@@ -253,82 +253,83 @@
const std::vector<
std::pair<std::string, std::variant<std::monostate, uint8_t>>>&
properties) {
- if (ec)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "PFR: Unable get PFR last events",
- phosphor::logging::entry("MSG=%s", ec.message().c_str()));
- return;
- }
- uint8_t lastRecoveryCount = 0;
- uint8_t lastPanicCount = 0;
- uint8_t lastMajorErr = 0;
- uint8_t lastMinorErr = 0;
-
- try
- {
- sdbusplus::unpackProperties(
- properties, "lastRecoveryCount", lastRecoveryCount,
- "lastPanicCount", lastPanicCount, "lastMajorErr", lastMajorErr,
- "lastMinorErr", lastMinorErr);
- }
- catch (const sdbusplus::exception::UnpackPropertyError& error)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "PFR: Unpack error",
- phosphor::logging::entry("MSG=%s", error.what()));
- return;
- }
-
- uint8_t currPanicCount = 0;
- if (0 == readCpldReg(ActionType::panicCount, currPanicCount))
- {
- if (lastPanicCount != currPanicCount)
+ if (ec)
{
- // Update cached data to dbus and log redfish
- // event by reading reason.
- handleLastCountChange(conn, "lastPanicCount", currPanicCount);
- if (currPanicCount)
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "PFR: Unable get PFR last events",
+ phosphor::logging::entry("MSG=%s", ec.message().c_str()));
+ return;
+ }
+ uint8_t lastRecoveryCount = 0;
+ uint8_t lastPanicCount = 0;
+ uint8_t lastMajorErr = 0;
+ uint8_t lastMinorErr = 0;
+
+ try
+ {
+ sdbusplus::unpackProperties(
+ properties, "lastRecoveryCount", lastRecoveryCount,
+ "lastPanicCount", lastPanicCount, "lastMajorErr",
+ lastMajorErr, "lastMinorErr", lastMinorErr);
+ }
+ catch (const sdbusplus::exception::UnpackPropertyError& error)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "PFR: Unpack error",
+ phosphor::logging::entry("MSG=%s", error.what()));
+ return;
+ }
+
+ uint8_t currPanicCount = 0;
+ if (0 == readCpldReg(ActionType::panicCount, currPanicCount))
+ {
+ if (lastPanicCount != currPanicCount)
{
- logLastPanicEvent();
+ // Update cached data to dbus and log redfish
+ // event by reading reason.
+ handleLastCountChange(conn, "lastPanicCount",
+ currPanicCount);
+ if (currPanicCount)
+ {
+ logLastPanicEvent();
+ }
}
}
- }
- uint8_t currRecoveryCount = 0;
- if (0 == readCpldReg(ActionType::recoveryCount, currRecoveryCount))
- {
- if (lastRecoveryCount != currRecoveryCount)
+ uint8_t currRecoveryCount = 0;
+ if (0 == readCpldReg(ActionType::recoveryCount, currRecoveryCount))
{
- // Update cached data to dbus and log redfish
- // event by reading reason.
- handleLastCountChange(conn, "lastRecoveryCount",
- currRecoveryCount);
- if (currRecoveryCount)
+ if (lastRecoveryCount != currRecoveryCount)
{
- logLastRecoveryEvent();
+ // Update cached data to dbus and log redfish
+ // event by reading reason.
+ handleLastCountChange(conn, "lastRecoveryCount",
+ currRecoveryCount);
+ if (currRecoveryCount)
+ {
+ logLastRecoveryEvent();
+ }
}
}
- }
- uint8_t majorErr = 0;
- uint8_t minorErr = 0;
- if ((0 == readCpldReg(ActionType::majorError, majorErr)) &&
- (0 == readCpldReg(ActionType::minorError, minorErr)))
- {
- if ((lastMajorErr != majorErr) || (lastMinorErr != minorErr))
+ uint8_t majorErr = 0;
+ uint8_t minorErr = 0;
+ if ((0 == readCpldReg(ActionType::majorError, majorErr)) &&
+ (0 == readCpldReg(ActionType::minorError, minorErr)))
{
- // Update cached data to dbus and log redfish event by
- // reading reason.
- handleLastCountChange(conn, "lastMajorErr", majorErr);
- handleLastCountChange(conn, "lastMinorErr", minorErr);
- if (majorErr && minorErr)
+ if ((lastMajorErr != majorErr) || (lastMinorErr != minorErr))
{
- logResiliencyErrorEvent(majorErr, minorErr);
+ // Update cached data to dbus and log redfish event by
+ // reading reason.
+ handleLastCountChange(conn, "lastMajorErr", majorErr);
+ handleLastCountChange(conn, "lastMinorErr", minorErr);
+ if (majorErr && minorErr)
+ {
+ logResiliencyErrorEvent(majorErr, minorErr);
+ }
}
}
- }
- });
+ });
}
static void monitorPlatformStateChange(
@@ -339,19 +340,19 @@
stateTimer->expires_after(std::chrono::seconds(pollTimeout));
stateTimer->async_wait(
[&server, &conn](const boost::system::error_code& ec) {
- if (ec == boost::asio::error::operation_aborted)
- {
- // Timer reset.
- return;
- }
- if (ec)
- {
- // Platform State Monitor - Timer cancelled.
- return;
- }
- checkAndLogEvents(conn);
- monitorPlatformStateChange(server, conn);
- });
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ // Timer reset.
+ return;
+ }
+ if (ec)
+ {
+ // Platform State Monitor - Timer cancelled.
+ return;
+ }
+ checkAndLogEvents(conn);
+ monitorPlatformStateChange(server, conn);
+ });
}
void checkAndSetCheckpoint(sdbusplus::asio::object_server& server,
@@ -361,51 +362,51 @@
conn->async_method_call(
[&server, &conn](boost::system::error_code ec,
const std::variant<uint64_t>& value) {
- if (!ec)
- {
- if (std::get<uint64_t>(value))
+ if (!ec)
{
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "BMC boot completed. Setting checkpoint 9.");
- if (!bmcBootCompleteChkPointDone)
+ if (std::get<uint64_t>(value))
{
- setBMCBootCompleteChkPoint(bmcBootFinishedChkPoint);
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "BMC boot completed. Setting checkpoint 9.");
+ if (!bmcBootCompleteChkPointDone)
+ {
+ setBMCBootCompleteChkPoint(bmcBootFinishedChkPoint);
+ }
+ return;
}
- return;
}
- }
- else
- {
- // Failed to get data from systemd. System might not
- // be ready yet. Attempt again for data.
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "aync call failed to get FinishTimestamp.",
- phosphor::logging::entry("MSG=%s", ec.message().c_str()));
- }
- // FIX-ME: Latest up-stream sync caused issue in receiving
- // StartupFinished signal. Unable to get StartupFinished signal
- // from systemd1 hence using poll method too, to trigger it
- // properly.
- constexpr size_t pollTimeout = 10; // seconds
- initTimer->expires_after(std::chrono::seconds(pollTimeout));
- initTimer->async_wait(
- [&server, &conn](const boost::system::error_code& ec) {
- if (ec == boost::asio::error::operation_aborted)
+ else
{
- // Timer reset.
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "Set boot Checkpoint - Timer aborted or stopped.");
- return;
- }
- if (ec)
- {
+ // Failed to get data from systemd. System might not
+ // be ready yet. Attempt again for data.
phosphor::logging::log<phosphor::logging::level::ERR>(
- "Set boot Checkpoint - async wait error.");
- return;
+ "aync call failed to get FinishTimestamp.",
+ phosphor::logging::entry("MSG=%s", ec.message().c_str()));
}
- checkAndSetCheckpoint(server, conn);
- });
- },
+ // FIX-ME: Latest up-stream sync caused issue in receiving
+ // StartupFinished signal. Unable to get StartupFinished signal
+ // from systemd1 hence using poll method too, to trigger it
+ // properly.
+ constexpr size_t pollTimeout = 10; // seconds
+ initTimer->expires_after(std::chrono::seconds(pollTimeout));
+ initTimer->async_wait(
+ [&server, &conn](const boost::system::error_code& ec) {
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ // Timer reset.
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "Set boot Checkpoint - Timer aborted or stopped.");
+ return;
+ }
+ if (ec)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Set boot Checkpoint - async wait error.");
+ return;
+ }
+ checkAndSetCheckpoint(server, conn);
+ });
+ },
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
"org.freedesktop.DBus.Properties", "Get",
"org.freedesktop.systemd1.Manager", "FinishTimestamp");
@@ -422,14 +423,14 @@
"member='StartupFinished',path='/org/freedesktop/systemd1',"
"interface='org.freedesktop.systemd1.Manager'",
[&server, &conn](sdbusplus::message_t& msg) {
- if (!bmcBootCompleteChkPointDone)
- {
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "BMC boot completed(StartupFinished). Setting "
- "checkpoint 9.");
- setBMCBootCompleteChkPoint(bmcBootFinishedChkPoint);
- }
- });
+ if (!bmcBootCompleteChkPointDone)
+ {
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "BMC boot completed(StartupFinished). Setting "
+ "checkpoint 9.");
+ setBMCBootCompleteChkPoint(bmcBootFinishedChkPoint);
+ }
+ });
checkAndSetCheckpoint(server, conn);
// Capture the Chassis state and Start the monitor timer
@@ -442,37 +443,38 @@
"sender='xyz.openbmc_project.State.Chassis', "
"arg0namespace='xyz.openbmc_project.State.Chassis'",
[&server, &conn](sdbusplus::message_t& message) {
- std::string intfName;
- std::map<std::string, std::variant<std::string>> properties;
- message.read(intfName, properties);
+ std::string intfName;
+ std::map<std::string, std::variant<std::string>> properties;
+ message.read(intfName, properties);
- const auto it = properties.find("CurrentPowerState");
- if (it != properties.end())
- {
- const std::string* state = std::get_if<std::string>(&it->second);
- if (state != nullptr)
+ const auto it = properties.find("CurrentPowerState");
+ if (it != properties.end())
{
- if ((*state ==
- "xyz.openbmc_project.State.Chassis.PowerState.On") &&
- (!stateTimerRunning))
+ const std::string* state =
+ std::get_if<std::string>(&it->second);
+ if (state != nullptr)
{
- stateTimerRunning = true;
- monitorPlatformStateChange(server, conn);
+ if ((*state ==
+ "xyz.openbmc_project.State.Chassis.PowerState.On") &&
+ (!stateTimerRunning))
+ {
+ stateTimerRunning = true;
+ monitorPlatformStateChange(server, conn);
+ }
+ else if ((*state == "xyz.openbmc_project.State.Chassis."
+ "PowerState.Off") &&
+ (stateTimerRunning))
+ {
+ stateTimer->cancel();
+ checkAndLogEvents(conn);
+ stateTimerRunning = false;
+ }
}
- else if ((*state == "xyz.openbmc_project.State.Chassis."
- "PowerState.Off") &&
- (stateTimerRunning))
- {
- stateTimer->cancel();
- checkAndLogEvents(conn);
- stateTimerRunning = false;
- }
- }
- // Update the D-Bus properties when chassis state changes.
- updateDbusPropertiesCache();
- }
- });
+ // Update the D-Bus properties when chassis state changes.
+ updateDbusPropertiesCache();
+ }
+ });
// Capture the Host state and Start the monitor timer
// if state changed to 'Running'. Run timer until OS boot.
@@ -484,39 +486,40 @@
"sender='xyz.openbmc_project.State.Chassis', "
"arg0namespace='xyz.openbmc_project.State.Host'",
[&server, &conn](sdbusplus::message_t& message) {
- std::string intfName;
- std::map<std::string, std::variant<std::string>> properties;
- message.read(intfName, properties);
+ std::string intfName;
+ std::map<std::string, std::variant<std::string>> properties;
+ message.read(intfName, properties);
- const auto it = properties.find("CurrentHostState");
- if (it != properties.end())
- {
- const std::string* state = std::get_if<std::string>(&it->second);
- if (state != nullptr)
+ const auto it = properties.find("CurrentHostState");
+ if (it != properties.end())
{
- if ((*state ==
- "xyz.openbmc_project.State.Host.HostState.Running") &&
- (!stateTimerRunning))
+ const std::string* state =
+ std::get_if<std::string>(&it->second);
+ if (state != nullptr)
{
- stateTimerRunning = true;
- monitorPlatformStateChange(server, conn);
+ if ((*state ==
+ "xyz.openbmc_project.State.Host.HostState.Running") &&
+ (!stateTimerRunning))
+ {
+ stateTimerRunning = true;
+ monitorPlatformStateChange(server, conn);
+ }
+ else if (((*state == "xyz.openbmc_project.State.Host."
+ "HostState.Off") ||
+ (*state == "xyz.openbmc_project.State.Host."
+ "HostState.Quiesced")) &&
+ (stateTimerRunning))
+ {
+ stateTimer->cancel();
+ checkAndLogEvents(conn);
+ stateTimerRunning = false;
+ }
}
- else if (((*state == "xyz.openbmc_project.State.Host."
- "HostState.Off") ||
- (*state == "xyz.openbmc_project.State.Host."
- "HostState.Quiesced")) &&
- (stateTimerRunning))
- {
- stateTimer->cancel();
- checkAndLogEvents(conn);
- stateTimerRunning = false;
- }
- }
- // Update the D-Bus properties when host state changes.
- updateDbusPropertiesCache();
- }
- });
+ // Update the D-Bus properties when host state changes.
+ updateDbusPropertiesCache();
+ }
+ });
// Capture the OS state change and stop monitor timer
// if OS boots completely or becomes Inactive.
@@ -528,40 +531,41 @@
"sender='xyz.openbmc_project.State.Chassis', "
"arg0namespace='xyz.openbmc_project.State.OperatingSystem.Status'",
[&server, &conn](sdbusplus::message_t& message) {
- std::string intfName;
- std::map<std::string, std::variant<std::string>> properties;
- message.read(intfName, properties);
+ std::string intfName;
+ std::map<std::string, std::variant<std::string>> properties;
+ message.read(intfName, properties);
- const auto it = properties.find("OperatingSystemState");
- if (it != properties.end())
- {
- const std::string* state = std::get_if<std::string>(&it->second);
- if (state != nullptr)
+ const auto it = properties.find("OperatingSystemState");
+ if (it != properties.end())
{
- // The short strings "BootComplete" and "Standby" are
- // deprecated in favor of the full enum strings
- // Support for the short strings will be removed in the
- // future.
- if (((*state == "BootComplete") ||
- (*state == "xyz.openbmc_project.State.OperatingSystem."
- "Status.OSStatus.BootComplete") ||
- (*state == "Inactive") ||
- (*state == "xyz.openbmc_project.State.OperatingSystem."
- "Status.OSStatus.Inactive")) &&
- (stateTimerRunning))
+ const std::string* state =
+ std::get_if<std::string>(&it->second);
+ if (state != nullptr)
{
- stateTimer->cancel();
- checkAndLogEvents(conn);
- stateTimerRunning = false;
- }
- else if (!stateTimerRunning)
- {
- stateTimerRunning = true;
- monitorPlatformStateChange(server, conn);
+ // The short strings "BootComplete" and "Standby" are
+ // deprecated in favor of the full enum strings
+ // Support for the short strings will be removed in the
+ // future.
+ if (((*state == "BootComplete") ||
+ (*state == "xyz.openbmc_project.State.OperatingSystem."
+ "Status.OSStatus.BootComplete") ||
+ (*state == "Inactive") ||
+ (*state == "xyz.openbmc_project.State.OperatingSystem."
+ "Status.OSStatus.Inactive")) &&
+ (stateTimerRunning))
+ {
+ stateTimer->cancel();
+ checkAndLogEvents(conn);
+ stateTimerRunning = false;
+ }
+ else if (!stateTimerRunning)
+ {
+ stateTimerRunning = true;
+ monitorPlatformStateChange(server, conn);
+ }
}
}
- }
- });
+ });
// First time, check and log events if any.
checkAndLogEvents(conn);
@@ -573,14 +577,14 @@
lg2::info("VERSION INFO - rot_fw_active - {VER}", "VER", cpldVersion);
conn->async_method_call(
[](const boost::system::error_code ec) {
- if (ec)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Unable to update rot_fw_active version",
- phosphor::logging::entry("MSG=%s", ec.message().c_str()));
- return;
- }
- },
+ if (ec)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to update rot_fw_active version",
+ phosphor::logging::entry("MSG=%s", ec.message().c_str()));
+ return;
+ }
+ },
"xyz.openbmc_project.Settings",
"/xyz/openbmc_project/software/rot_fw_active",
"org.freedesktop.DBus.Properties", "Set",
@@ -639,8 +643,8 @@
constexpr size_t timeout = 10; // seconds
pfrObjTimer->expires_after(std::chrono::seconds(timeout));
- pfrObjTimer->async_wait(
- [&conn, &server](const boost::system::error_code& ec) {
+ pfrObjTimer->async_wait([&conn,
+ &server](const boost::system::error_code& ec) {
if (ec)
{
if (ec == boost::asio::error::operation_aborted)
@@ -707,8 +711,8 @@
pfr::pfrConfigObject->updateProvisioningStatus();
if (pfr::pfrConfigObject->getPfrProvisioned())
{
- pfr::pfrPostcodeObject = std::make_unique<pfr::PfrPostcode>(server,
- conn);
+ pfr::pfrPostcodeObject =
+ std::make_unique<pfr::PfrPostcode>(server, conn);
}
}