Skip to content

Commit

Permalink
clang-format: re-format for clang-18
Browse files Browse the repository at this point in the history
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: I0f105c3310e87172c65a09a8787a2db5a4041cc0
Signed-off-by: Patrick Williams <[email protected]>
  • Loading branch information
williamspatrick committed Aug 16, 2024
1 parent 5d897e2 commit bd63bca
Show file tree
Hide file tree
Showing 29 changed files with 355 additions and 368 deletions.
7 changes: 4 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ IndentWidth: 4
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: OuterScope
LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
Expand All @@ -98,13 +98,14 @@ ObjCSpaceAfterProperty: false
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
Expand Down
4 changes: 2 additions & 2 deletions dbus/dbusactiveread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class DbusActiveRead : public ReadInterface
DbusActiveRead(sdbusplus::bus_t& bus, const std::string& path,
const std::string& service,
std::unique_ptr<DbusHelperInterface> helper) :
ReadInterface(),
_bus(bus), _path(path), _service(service), _helper(std::move(helper))
ReadInterface(), _bus(bus), _path(path), _service(service),
_helper(std::move(helper))
{}

ReadReturn read(void) override;
Expand Down
68 changes: 34 additions & 34 deletions dbus/dbusconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ inline std::string sensorNameToDbusName(const std::string& sensorName)
std::vector<std::string> getSelectedProfiles(sdbusplus::bus_t& bus)
{
std::vector<std::string> ret;
auto mapper = bus.new_method_call("xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper",
"GetSubTree");
auto mapper =
bus.new_method_call("xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree");
mapper.append("/", 0, std::array<const char*, 1>{thermalControlIface});
std::unordered_map<
std::string, std::unordered_map<std::string, std::vector<std::string>>>
Expand Down Expand Up @@ -281,8 +281,8 @@ inline void getCycleTimeSetting(
auto findAttributeName = zone.find(attributeName);
if (findAttributeName != zone.end())
{
double tmpAttributeValue = std::visit(VariantToDoubleVisitor(),
zone.at(attributeName));
double tmpAttributeValue =
std::visit(VariantToDoubleVisitor(), zone.at(attributeName));
if (tmpAttributeValue >= 1.0)
{
value = static_cast<uint64_t>(tmpAttributeValue);
Expand Down Expand Up @@ -380,10 +380,10 @@ void populatePidInfo(
getPIDAttribute(base, "OutLimitMax"));
info.pidInfo.outLim.min = std::visit(VariantToDoubleVisitor(),
getPIDAttribute(base, "OutLimitMin"));
info.pidInfo.slewNeg = std::visit(VariantToDoubleVisitor(),
getPIDAttribute(base, "SlewNeg"));
info.pidInfo.slewPos = std::visit(VariantToDoubleVisitor(),
getPIDAttribute(base, "SlewPos"));
info.pidInfo.slewNeg =
std::visit(VariantToDoubleVisitor(), getPIDAttribute(base, "SlewNeg"));
info.pidInfo.slewPos =
std::visit(VariantToDoubleVisitor(), getPIDAttribute(base, "SlewPos"));

bool checkHysterWithSetpt = false;
double negativeHysteresis = 0;
Expand All @@ -401,18 +401,18 @@ void populatePidInfo(
}
if (findNeg != base.end())
{
negativeHysteresis = std::visit(VariantToDoubleVisitor(),
findNeg->second);
negativeHysteresis =
std::visit(VariantToDoubleVisitor(), findNeg->second);
}
if (findPos != base.end())
{
positiveHysteresis = std::visit(VariantToDoubleVisitor(),
findPos->second);
positiveHysteresis =
std::visit(VariantToDoubleVisitor(), findPos->second);
}
if (findDerivative != base.end())
{
derivativeCoeff = std::visit(VariantToDoubleVisitor(),
findDerivative->second);
derivativeCoeff =
std::visit(VariantToDoubleVisitor(), findDerivative->second);
}

info.pidInfo.checkHysterWithSetpt = checkHysterWithSetpt;
Expand All @@ -432,16 +432,16 @@ bool init(sdbusplus::bus_t& bus, boost::asio::steady_timer& timer,

createMatches(bus, timer);

auto mapper = bus.new_method_call("xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper",
"GetSubTree");
mapper.append("/", 0,
std::array<const char*, 6>{
objectManagerInterface, pidConfigurationInterface,
pidZoneConfigurationInterface,
stepwiseConfigurationInterface, sensorInterface,
defaultPwmInterface});
auto mapper =
bus.new_method_call("xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree");
mapper.append(
"/", 0,
std::array<const char*, 6>{
objectManagerInterface, pidConfigurationInterface,
pidZoneConfigurationInterface, stepwiseConfigurationInterface,
sensorInterface, defaultPwmInterface});
std::unordered_map<
std::string, std::unordered_map<std::string, std::vector<std::string>>>
respData;
Expand Down Expand Up @@ -516,8 +516,8 @@ bool init(sdbusplus::bus_t& bus, boost::asio::steady_timer& timer,
catch (const sdbusplus::exception_t&)
{
// this shouldn't happen, probably means daemon crashed
throw std::runtime_error("Error getting managed objects from " +
owner.first);
throw std::runtime_error(
"Error getting managed objects from " + owner.first);
}

for (auto& pathPair : configuration)
Expand Down Expand Up @@ -562,8 +562,8 @@ bool init(sdbusplus::bus_t& bus, boost::asio::steady_timer& timer,
for (const std::string& profile : profiles)
{
if (std::find(selectedProfiles.begin(),
selectedProfiles.end(),
profile) != selectedProfiles.end())
selectedProfiles.end(), profile) !=
selectedProfiles.end())
{
found = true;
break;
Expand Down Expand Up @@ -908,11 +908,11 @@ bool init(sdbusplus::bus_t& bus, boost::asio::steady_timer& timer,
offsetType =
std::get<std::string>(findSetpointOffset->second);
if (std::find(thresholds::types.begin(),
thresholds::types.end(),
offsetType) == thresholds::types.end())
thresholds::types.end(), offsetType) ==
thresholds::types.end())
{
throw std::runtime_error("Unsupported type: " +
offsetType);
throw std::runtime_error(
"Unsupported type: " + offsetType);
}
}

Expand Down
8 changes: 4 additions & 4 deletions dbus/dbushelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ using namespace phosphor::logging;
std::string DbusHelper::getService(const std::string& intf,
const std::string& path)
{
auto mapper = _bus.new_method_call("xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper",
"GetObject");
auto mapper =
_bus.new_method_call("xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetObject");

mapper.append(path);
mapper.append(std::vector<std::string>({intf}));
Expand Down
9 changes: 4 additions & 5 deletions dbus/dbuspassive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ DbusPassive::DbusPassive(
std::unique_ptr<DbusHelperInterface> helper,
const SensorProperties& settings, bool failed, const std::string& path,
const std::shared_ptr<DbusPassiveRedundancy>& redundancy) :
ReadInterface(),
_signal(bus, getMatch(path), dbusHandleSignal, this), _id(id),
_helper(std::move(helper)), _failed(failed), path(path),
ReadInterface(), _signal(bus, getMatch(path), dbusHandleSignal, this),
_id(id), _helper(std::move(helper)), _failed(failed), path(path),
redundancy(redundancy)

{
Expand Down Expand Up @@ -277,8 +276,8 @@ int handleSensorValue(sdbusplus::message_t& msg, DbusPassive* owner)
auto valPropMap = msgData.find("Value");
if (valPropMap != msgData.end())
{
double value = std::visit(VariantToDoubleVisitor(),
valPropMap->second);
double value =
std::visit(VariantToDoubleVisitor(), valPropMap->second);

owner->updateValue(value, false);
}
Expand Down
107 changes: 54 additions & 53 deletions dbus/dbuspassiveredundancy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,56 +50,57 @@ DbusPassiveRedundancy::DbusPassiveRedundancy(sdbusplus::bus_t& bus) :
"type='signal',member='PropertiesChanged',arg0namespace='" +
std::string(redundancy::interface) + "'",
std::move([this](sdbusplus::message_t& message) {
std::string objectName;
std::unordered_map<std::string,
std::variant<std::string, std::vector<std::string>>>
result;
try
{
message.read(objectName, result);
}
catch (const sdbusplus::exception_t&)
{
std::cerr << "Error reading match data";
return;
}
auto findStatus = result.find("Status");
if (findStatus == result.end())
{
return;
}
std::string status = std::get<std::string>(findStatus->second);

auto methodCall =
passiveBus.new_method_call(message.get_sender(), message.get_path(),
properties::interface, properties::get);
methodCall.append(redundancy::interface, redundancy::collection);
std::variant<std::vector<std::string>> collection;

try
{
auto reply = passiveBus.call(methodCall);
reply.read(collection);
}
catch (const sdbusplus::exception_t&)
{
std::cerr << "Error reading match data";
return;
}

auto data = std::get<std::vector<std::string>>(collection);
if (status.rfind("Failed") != std::string::npos)
{
failed.insert(data.begin(), data.end());
}
else
{
for (const auto& d : data)
{
failed.erase(d);
}
}
})),
std::string objectName;
std::unordered_map<
std::string,
std::variant<std::string, std::vector<std::string>>>
result;
try
{
message.read(objectName, result);
}
catch (const sdbusplus::exception_t&)
{
std::cerr << "Error reading match data";
return;
}
auto findStatus = result.find("Status");
if (findStatus == result.end())
{
return;
}
std::string status = std::get<std::string>(findStatus->second);

auto methodCall = passiveBus.new_method_call(
message.get_sender(), message.get_path(),
properties::interface, properties::get);
methodCall.append(redundancy::interface, redundancy::collection);
std::variant<std::vector<std::string>> collection;

try
{
auto reply = passiveBus.call(methodCall);
reply.read(collection);
}
catch (const sdbusplus::exception_t&)
{
std::cerr << "Error reading match data";
return;
}

auto data = std::get<std::vector<std::string>>(collection);
if (status.rfind("Failed") != std::string::npos)
{
failed.insert(data.begin(), data.end());
}
else
{
for (const auto& d : data)
{
failed.erase(d);
}
}
})),
passiveBus(bus)
{
populateFailures();
Expand Down Expand Up @@ -141,9 +142,9 @@ void DbusPassiveRedundancy::populateFailures(void)
{
for (const auto& [owner, _] : interfaceDict)
{
auto call = passiveBus.new_method_call(owner.c_str(), path.c_str(),
properties::interface,
properties::getAll);
auto call = passiveBus.new_method_call(
owner.c_str(), path.c_str(), properties::interface,
properties::getAll);
call.append(redundancy::interface);

std::unordered_map<
Expand Down
19 changes: 9 additions & 10 deletions dbus/dbuswrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ void DbusWritePercent::write(double value, bool force, int64_t* written)
}
}
auto writeBus = sdbusplus::bus::new_default();
auto mesg = writeBus.new_method_call(connectionName.c_str(), path.c_str(),
"org.freedesktop.DBus.Properties",
"Set");
auto mesg =
writeBus.new_method_call(connectionName.c_str(), path.c_str(),
"org.freedesktop.DBus.Properties", "Set");
mesg.append(pwmInterface, "Target",
std::variant<uint64_t>(static_cast<uint64_t>(ovalue)));

Expand All @@ -103,10 +103,9 @@ void DbusWritePercent::write(double value, bool force, int64_t* written)
return;
}

std::unique_ptr<WriteInterface>
DbusWrite::createDbusWrite(const std::string& path, int64_t min,
int64_t max,
std::unique_ptr<DbusHelperInterface> helper)
std::unique_ptr<WriteInterface> DbusWrite::createDbusWrite(
const std::string& path, int64_t min, int64_t max,
std::unique_ptr<DbusHelperInterface> helper)
{
std::string connectionName;

Expand Down Expand Up @@ -141,9 +140,9 @@ void DbusWrite::write(double value, bool force, int64_t* written)
}
}
auto writeBus = sdbusplus::bus::new_default();
auto mesg = writeBus.new_method_call(connectionName.c_str(), path.c_str(),
"org.freedesktop.DBus.Properties",
"Set");
auto mesg =
writeBus.new_method_call(connectionName.c_str(), path.c_str(),
"org.freedesktop.DBus.Properties", "Set");
mesg.append(pwmInterface, "Target",
std::variant<uint64_t>(static_cast<uint64_t>(value)));

Expand Down
6 changes: 2 additions & 4 deletions dbus/dbuswrite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class DbusWritePercent : public WriteInterface

DbusWritePercent(const std::string& path, int64_t min, int64_t max,
const std::string& connectionName) :
WriteInterface(min, max),
path(path), connectionName(connectionName)
WriteInterface(min, max), path(path), connectionName(connectionName)
{}

void write(double value) override;
Expand All @@ -59,8 +58,7 @@ class DbusWrite : public WriteInterface

DbusWrite(const std::string& path, int64_t min, int64_t max,
const std::string& connectionName) :
WriteInterface(min, max),
path(path), connectionName(connectionName)
WriteInterface(min, max), path(path), connectionName(connectionName)
{}

void write(double value) override;
Expand Down
8 changes: 4 additions & 4 deletions ipmi/main_ipmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void setupGlobalOemFanControl()
oem::obmcOemNumber, oem::Cmd::fanManualCmd);

using namespace std::placeholders;
router->registerHandler(oem::obmcOemNumber, oem::Cmd::fanManualCmd,
std::bind(pid_control::ipmi::manualModeControl,
&pid_control::ipmi::handler, _1, _2, _3,
_4));
router->registerHandler(
oem::obmcOemNumber, oem::Cmd::fanManualCmd,
std::bind(pid_control::ipmi::manualModeControl,
&pid_control::ipmi::handler, _1, _2, _3, _4));
}
Loading

0 comments on commit bd63bca

Please sign in to comment.