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: I75bbf0de40859a5e507455a52ceaef9be5b686c7
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/file.hpp b/file.hpp
index aaf1062..968be37 100644
--- a/file.hpp
+++ b/file.hpp
@@ -40,9 +40,7 @@
* @param[in] removeOnExit - File to be removed at exit or no
*/
File(const std::string& name, const std::string& mode,
- bool removeOnExit = false) :
- name(name),
- removeOnExit(removeOnExit)
+ bool removeOnExit = false) : name(name), removeOnExit(removeOnExit)
{
fp = fopen(name.c_str(), mode.c_str());
}
@@ -55,9 +53,7 @@
* @param[in] removeOnExit - File to be removed at exit or no
*/
File(int fd, const std::string& name, const std::string& mode,
- bool removeOnExit = false) :
- name(name),
- removeOnExit(removeOnExit)
+ bool removeOnExit = false) : name(name), removeOnExit(removeOnExit)
{
fp = fdopen(fd, mode.c_str());
}
diff --git a/phosphor-ldap-config/ldap_config.cpp b/phosphor-ldap-config/ldap_config.cpp
index 5717ad5..e7fb645 100644
--- a/phosphor-ldap-config/ldap_config.cpp
+++ b/phosphor-ldap-config/ldap_config.cpp
@@ -50,18 +50,17 @@
using Val = std::string;
using ConfigInfo = std::map<Key, Val>;
-Config::Config(sdbusplus::bus_t& bus, const char* path, const char* filePath,
- const char* caCertFile, const char* certFile, bool secureLDAP,
- std::string ldapServerURI, std::string ldapBindDN,
- std::string ldapBaseDN, std::string&& ldapBindDNPassword,
- ConfigIface::SearchScope ldapSearchScope,
- ConfigIface::Type ldapType, bool ldapServiceEnabled,
- std::string userNameAttr, std::string groupNameAttr,
- ConfigMgr& parent) :
- Ifaces(bus, path, Ifaces::action::defer_emit),
- secureLDAP(secureLDAP), ldapBindPassword(std::move(ldapBindDNPassword)),
- tlsCacertFile(caCertFile), tlsCertFile(certFile), configFilePath(filePath),
- objectPath(path), bus(bus), parent(parent),
+Config::Config(
+ sdbusplus::bus_t& bus, const char* path, const char* filePath,
+ const char* caCertFile, const char* certFile, bool secureLDAP,
+ std::string ldapServerURI, std::string ldapBindDN, std::string ldapBaseDN,
+ std::string&& ldapBindDNPassword, ConfigIface::SearchScope ldapSearchScope,
+ ConfigIface::Type ldapType, bool ldapServiceEnabled,
+ std::string userNameAttr, std::string groupNameAttr, ConfigMgr& parent) :
+ Ifaces(bus, path, Ifaces::action::defer_emit), secureLDAP(secureLDAP),
+ ldapBindPassword(std::move(ldapBindDNPassword)), tlsCacertFile(caCertFile),
+ tlsCertFile(certFile), configFilePath(filePath), objectPath(path), bus(bus),
+ parent(parent),
certificateInstalledSignal(
bus, sdbusplus::bus::match::rules::interfacesAdded(certRootPath),
std::bind(std::mem_fn(&Config::certificateInstalled), this,
@@ -110,9 +109,9 @@
Config::Config(sdbusplus::bus_t& bus, const char* path, const char* filePath,
const char* caCertFile, const char* certFile,
ConfigIface::Type ldapType, ConfigMgr& parent) :
- Ifaces(bus, path, Ifaces::action::defer_emit),
- secureLDAP(false), tlsCacertFile(caCertFile), tlsCertFile(certFile),
- configFilePath(filePath), objectPath(path), bus(bus), parent(parent),
+ Ifaces(bus, path, Ifaces::action::defer_emit), secureLDAP(false),
+ tlsCacertFile(caCertFile), tlsCertFile(certFile), configFilePath(filePath),
+ objectPath(path), bus(bus), parent(parent),
certificateInstalledSignal(
bus, sdbusplus::bus::match::rules::interfacesAdded(certRootPath),
std::bind(std::mem_fn(&Config::certificateInstalled), this,
diff --git a/phosphor-ldap-config/ldap_config_mgr.hpp b/phosphor-ldap-config/ldap_config_mgr.hpp
index 13211c8..3c969a7 100644
--- a/phosphor-ldap-config/ldap_config_mgr.hpp
+++ b/phosphor-ldap-config/ldap_config_mgr.hpp
@@ -17,10 +17,10 @@
static constexpr auto defaultNslcdFile = "nslcd.conf.default";
static constexpr auto nsSwitchFile = "nsswitch.conf";
-static auto openLDAPDbusObjectPath = std::string(LDAP_CONFIG_ROOT) +
- "/openldap";
-static auto adDbusObjectPath = std::string(LDAP_CONFIG_ROOT) +
- "/active_directory";
+static auto openLDAPDbusObjectPath =
+ std::string(LDAP_CONFIG_ROOT) + "/openldap";
+static auto adDbusObjectPath =
+ std::string(LDAP_CONFIG_ROOT) + "/active_directory";
using CreateIface = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::User::Ldap::server::Create>;
@@ -72,13 +72,11 @@
* the username in the LDAP server.
* @returns the object path of the D-Bus object created.
*/
- std::string createConfig(std::string ldapServerURI, std::string ldapBindDN,
- std::string ldapBaseDN,
- std::string ldapBindDNPassword,
- CreateIface::SearchScope ldapSearchScope,
- CreateIface::Type ldapType,
- std::string groupNameAttribute,
- std::string userNameAttribute) override;
+ std::string createConfig(
+ std::string ldapServerURI, std::string ldapBindDN,
+ std::string ldapBaseDN, std::string ldapBindDNPassword,
+ CreateIface::SearchScope ldapSearchScope, CreateIface::Type ldapType,
+ std::string groupNameAttribute, std::string userNameAttribute) override;
/** @brief restarts given service
* @param[in] service - Service to be restarted.
diff --git a/phosphor-ldap-config/main.cpp b/phosphor-ldap-config/main.cpp
index be97abd..5386c0e 100644
--- a/phosphor-ldap-config/main.cpp
+++ b/phosphor-ldap-config/main.cpp
@@ -17,8 +17,8 @@
std::filesystem::path configDir =
std::filesystem::path(LDAP_CONFIG_FILE).parent_path();
- if (!std::filesystem::exists(configDir /
- phosphor::ldap::defaultNslcdFile) ||
+ if (!std::filesystem::exists(
+ configDir / phosphor::ldap::defaultNslcdFile) ||
!std::filesystem::exists(configDir / phosphor::ldap::nsSwitchFile))
{
lg2::error("Failed to start phosphor-ldap-manager, configfile(s) are "
diff --git a/phosphor-ldap-config/utils.cpp b/phosphor-ldap-config/utils.cpp
index 4ad69d9..f6efdd9 100644
--- a/phosphor-ldap-config/utils.cpp
+++ b/phosphor-ldap-config/utils.cpp
@@ -57,8 +57,8 @@
auto result = getaddrinfo(ludppPtr->lud_host, nullptr, &hints, &servinfo);
auto cleanupFunc = [](addrinfo* servinfo) { freeaddrinfo(servinfo); };
- std::unique_ptr<addrinfo, decltype(cleanupFunc)> servinfoPtr(servinfo,
- cleanupFunc);
+ std::unique_ptr<addrinfo, decltype(cleanupFunc)> servinfoPtr(
+ servinfo, cleanupFunc);
if (result)
{
diff --git a/test/user_mgr_test.cpp b/test/user_mgr_test.cpp
index 664def2..f07b00c 100644
--- a/test/user_mgr_test.cpp
+++ b/test/user_mgr_test.cpp
@@ -236,8 +236,8 @@
{
std::ofstream outputFileStream;
- outputFileStream.exceptions(std::ofstream::failbit | std::ofstream::badbit |
- std::ofstream::eofbit);
+ outputFileStream.exceptions(
+ std::ofstream::failbit | std::ofstream::badbit | std::ofstream::eofbit);
outputFileStream.open(filePath, std::ios::out);
outputFileStream << str << "\n" << std::flush;
@@ -274,16 +274,18 @@
ON_CALL(*this, executeUserAdd(testing::_, testing::_, testing::_,
testing::Eq(true)))
.WillByDefault([this]() {
- ON_CALL(*this, isUserEnabled).WillByDefault(testing::Return(true));
- testing::Return();
- });
+ ON_CALL(*this, isUserEnabled)
+ .WillByDefault(testing::Return(true));
+ testing::Return();
+ });
ON_CALL(*this, executeUserAdd(testing::_, testing::_, testing::_,
testing::Eq(false)))
.WillByDefault([this]() {
- ON_CALL(*this, isUserEnabled).WillByDefault(testing::Return(false));
- testing::Return();
- });
+ ON_CALL(*this, isUserEnabled)
+ .WillByDefault(testing::Return(false));
+ testing::Return();
+ });
ON_CALL(*this, executeUserDelete).WillByDefault(testing::Return());
@@ -300,16 +302,18 @@
ON_CALL(*this,
executeUserModifyUserEnable(testing::_, testing::Eq(true)))
.WillByDefault([this]() {
- ON_CALL(*this, isUserEnabled).WillByDefault(testing::Return(true));
- testing::Return();
- });
+ ON_CALL(*this, isUserEnabled)
+ .WillByDefault(testing::Return(true));
+ testing::Return();
+ });
ON_CALL(*this,
executeUserModifyUserEnable(testing::_, testing::Eq(false)))
.WillByDefault([this]() {
- ON_CALL(*this, isUserEnabled).WillByDefault(testing::Return(false));
- testing::Return();
- });
+ ON_CALL(*this, isUserEnabled)
+ .WillByDefault(testing::Return(false));
+ testing::Return();
+ });
ON_CALL(*this, executeGroupCreation(testing::_))
.WillByDefault(testing::Return());
diff --git a/user_mgr.cpp b/user_mgr.cpp
index de4b570..09d82b1 100644
--- a/user_mgr.cpp
+++ b/user_mgr.cpp
@@ -109,8 +109,8 @@
{
// The hardcoded groups in OpenBMC projects
-constexpr std::array<const char*, 4> predefinedGroups = {"redfish", "ipmi",
- "ssh", "hostconsole"};
+constexpr std::array<const char*, 4> predefinedGroups = {
+ "redfish", "ipmi", "ssh", "hostconsole"};
// These prefixes are for Dynamic Redfish authorization. See
// https://github.com/openbmc/docs/blob/master/designs/redfish-authorization.md
@@ -154,10 +154,10 @@
}
return std::accumulate(std::next(vec.begin()), vec.end(), vec[0],
[](std::string&& val, std::string_view element) {
- val += ',';
- val += element;
- return val;
- });
+ val += ',';
+ val += element;
+ return val;
+ });
}
bool removeStringFromCSV(std::string& csvStr, const std::string& delStr)
@@ -894,8 +894,8 @@
buflen = 1024;
}
std::vector<char> buffer(buflen);
- auto status = getspnam_r(userName.c_str(), &spwd, buffer.data(), buflen,
- &spwdPtr);
+ auto status =
+ getspnam_r(userName.c_str(), &spwd, buffer.data(), buflen, &spwdPtr);
// On success, getspnam_r() returns zero, and sets *spwdPtr to spwd.
// If no matching password record was found, these functions return 0
// and store NULL in *spwdPtr
@@ -1042,8 +1042,8 @@
std::string basePath = "/xyz/openbmc_project/user/ldap/openldap";
std::string interface = "xyz.openbmc_project.User.Ldap.Config";
- auto ldapMgmtService = getServiceName(std::move(basePath),
- std::move(interface));
+ auto ldapMgmtService =
+ getServiceName(std::move(basePath), std::move(interface));
auto method = bus.new_method_call(
ldapMgmtService.c_str(), ldapMgrObjBasePath,
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");