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: I2817d88d8d4d027c6ac47943486c02811702cabf
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
@@ -98,13 +98,14 @@
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
diff --git a/include/host_error_event_monitor.hpp b/include/host_error_event_monitor.hpp
index 25683e0..9823623 100644
--- a/include/host_error_event_monitor.hpp
+++ b/include/host_error_event_monitor.hpp
@@ -67,8 +67,8 @@
}
std::string eventName = objectPath.substr(objectPath.find_last_of('/') + 1,
objectPath.length());
- std::string message = (assert) ? eventName + " Asserted"
- : eventName + " De-Asserted";
+ std::string message =
+ (assert) ? eventName + " Asserted" : eventName + " De-Asserted";
uint8_t selType = (msgInterface.ends_with("ThermalTrip")) ? 0x01 : 0x00;
std::vector<uint8_t> selData{selType, 0xff, 0xff};
@@ -88,7 +88,7 @@
"HostErrorMonitor.Processor." +
iter->first + "'",
[conn, iter](sdbusplus::message_t& msg) {
- hostErrorEventMonitor(conn, msg);
- });
+ hostErrorEventMonitor(conn, msg);
+ });
}
}
diff --git a/include/sensorutils.hpp b/include/sensorutils.hpp
index af979b0..cc95cf5 100644
--- a/include/sensorutils.hpp
+++ b/include/sensorutils.hpp
@@ -169,10 +169,9 @@
// To use with Wolfram Alpha, make all variables single letters
// bExp becomes E, rExp becomes R
// https://www.wolframalpha.com/input/?i=y%3D%28%28M*x%29%2B%28B*%2810%5EE%29%29%29*%2810%5ER%29
-static inline bool getSensorAttributes(const double max, const double min,
- int16_t& mValue, int8_t& rExp,
- int16_t& bValue, int8_t& bExp,
- bool& bSigned)
+static inline bool getSensorAttributes(
+ const double max, const double min, int16_t& mValue, int8_t& rExp,
+ int16_t& bValue, int8_t& bExp, bool& bSigned)
{
if (!(std::isfinite(min)))
{
@@ -263,9 +262,8 @@
// Step 4: Constrain B, and set bExp accordingly
if (!(scaleFloatExp(dB, bExp)))
{
- std::cerr << "getSensorAttributes: Offset (B=" << dB
- << ", bExp=" << (int)bExp
- << ") exceeds multiplier scale (M=" << dM
+ std::cerr << "getSensorAttributes: Offset (B=" << dB << ", bExp="
+ << (int)bExp << ") exceeds multiplier scale (M=" << dM
<< ", rExp=" << (int)rExp << ")\n";
return false;
}
@@ -278,10 +276,9 @@
return true;
}
-static inline uint8_t
- scaleIPMIValueFromDouble(const double value, const int16_t mValue,
- const int8_t rExp, const int16_t bValue,
- const int8_t bExp, const bool bSigned)
+static inline uint8_t scaleIPMIValueFromDouble(
+ const double value, const int16_t mValue, const int8_t rExp,
+ const int16_t bValue, const int8_t bExp, const bool bSigned)
{
// Avoid division by zero below
if (mValue == 0)
@@ -336,8 +333,8 @@
int8_t bExp = 0;
bool bSigned = false;
- bool result = getSensorAttributes(max, min, mValue, rExp, bValue, bExp,
- bSigned);
+ bool result =
+ getSensorAttributes(max, min, mValue, rExp, bValue, bExp, bSigned);
if (!result)
{
throw std::runtime_error("Illegal sensor attributes");
diff --git a/include/threshold_alarm_event_monitor.hpp b/include/threshold_alarm_event_monitor.hpp
index fc0d383..6b0544a 100644
--- a/include/threshold_alarm_event_monitor.hpp
+++ b/include/threshold_alarm_event_monitor.hpp
@@ -209,8 +209,8 @@
<< "\n";
return;
}
- double thresholdVal = std::visit(ipmi::VariantToDoubleVisitor(),
- thresholdValue);
+ double thresholdVal =
+ std::visit(ipmi::VariantToDoubleVisitor(), thresholdValue);
double scale = 0;
auto findScale = sensorValue.find("Scale");
@@ -254,7 +254,7 @@
static_cast<sdbusplus::bus_t&>(*conn),
"type='signal',member=" + iter->first,
[conn, iter](sdbusplus::message_t& msg) {
- generateEvent(iter->first, conn, msg);
- });
+ generateEvent(iter->first, conn, msg);
+ });
}
}
diff --git a/include/threshold_event_monitor.hpp b/include/threshold_event_monitor.hpp
index cea25c1..685bb4e 100644
--- a/include/threshold_event_monitor.hpp
+++ b/include/threshold_event_monitor.hpp
@@ -179,15 +179,15 @@
<< msg.get_path() << "\n";
return;
}
- double thresholdVal = std::visit(ipmi::VariantToDoubleVisitor(),
- thresholdValue);
+ double thresholdVal =
+ std::visit(ipmi::VariantToDoubleVisitor(), thresholdValue);
double scale = 0;
auto findScale = sensorValue.find("Scale");
if (findScale != sensorValue.end())
{
- scale = std::visit(ipmi::VariantToDoubleVisitor(),
- findScale->second);
+ scale =
+ std::visit(ipmi::VariantToDoubleVisitor(), findScale->second);
thresholdVal *= std::pow(10, scale);
}
try
@@ -202,8 +202,8 @@
std::string threshold;
std::string direction;
- std::string redfishMessageID = "OpenBMC." +
- openBMCMessageRegistryVersion;
+ std::string redfishMessageID =
+ "OpenBMC." + openBMCMessageRegistryVersion;
enum EventType
{
eventNone,
diff --git a/src/sel_logger.cpp b/src/sel_logger.cpp
index 95a4602..2c1d1fe 100644
--- a/src/sel_logger.cpp
+++ b/src/sel_logger.cpp
@@ -377,20 +377,20 @@
"xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
"xyz.openbmc_project.Logging.Create", "Create");
- std::string journalMsg(message + " from " + path + ": " +
- " RecordType=" + std::to_string(selSystemType) +
- ", GeneratorID=" + std::to_string(genId) +
- ", EventDir=" + std::to_string(assert) +
- ", EventData=" + selDataStr);
+ std::string journalMsg(
+ message + " from " + path + ": " +
+ " RecordType=" + std::to_string(selSystemType) +
+ ", GeneratorID=" + std::to_string(genId) +
+ ", EventDir=" + std::to_string(assert) + ", EventData=" + selDataStr);
- AddToLog.append(journalMsg,
- "xyz.openbmc_project.Logging.Entry.Level.Informational",
- std::map<std::string, std::string>(
- {{"SENSOR_PATH", path},
- {"GENERATOR_ID", std::to_string(genId)},
- {"RECORD_TYPE", std::to_string(selSystemType)},
- {"EVENT_DIR", std::to_string(assert)},
- {"SENSOR_DATA", selDataStr}}));
+ AddToLog.append(
+ journalMsg, "xyz.openbmc_project.Logging.Entry.Level.Informational",
+ std::map<std::string, std::string>(
+ {{"SENSOR_PATH", path},
+ {"GENERATOR_ID", std::to_string(genId)},
+ {"RECORD_TYPE", std::to_string(selSystemType)},
+ {"EVENT_DIR", std::to_string(assert)},
+ {"SENSOR_DATA", selDataStr}}));
conn->call(AddToLog);
return 0;
#else
@@ -432,14 +432,14 @@
", GeneratorID=" + std::to_string(0) +
", EventDir=" + std::to_string(0) + ", EventData=" + selDataStr);
- AddToLog.append(journalMsg,
- "xyz.openbmc_project.Logging.Entry.Level.Informational",
- std::map<std::string, std::string>(
- {{"SENSOR_PATH", ""},
- {"GENERATOR_ID", std::to_string(0)},
- {"RECORD_TYPE", std::to_string(recordType)},
- {"EVENT_DIR", std::to_string(0)},
- {"SENSOR_DATA", selDataStr}}));
+ AddToLog.append(
+ journalMsg, "xyz.openbmc_project.Logging.Entry.Level.Informational",
+ std::map<std::string, std::string>(
+ {{"SENSOR_PATH", ""},
+ {"GENERATOR_ID", std::to_string(0)},
+ {"RECORD_TYPE", std::to_string(recordType)},
+ {"EVENT_DIR", std::to_string(0)},
+ {"SENSOR_DATA", selDataStr}}));
conn->call(AddToLog);
return 0;
#else
@@ -481,15 +481,16 @@
[conn](const std::string& message, const std::string& path,
const std::vector<uint8_t>& selData, const bool& assert,
const uint16_t& genId) {
- return selAddSystemRecord(conn, message, path, selData, assert, genId);
- });
+ return selAddSystemRecord(conn, message, path, selData, assert,
+ genId);
+ });
// Add a new OEM SEL entry
- ifaceAddSel->register_method("IpmiSelAddOem",
- [conn](const std::string& message,
- const std::vector<uint8_t>& selData,
- const uint8_t& recordType) {
- return selAddOemRecord(conn, message, selData, recordType);
- });
+ ifaceAddSel->register_method(
+ "IpmiSelAddOem",
+ [conn](const std::string& message, const std::vector<uint8_t>& selData,
+ const uint8_t& recordType) {
+ return selAddOemRecord(conn, message, selData, recordType);
+ });
#ifndef SEL_LOGGER_SEND_TO_LOGGING_SERVICE
// Clear SEL entries