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: I9ff64598516b419af832abda0fce295f722f6969
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/src/srvcfg_manager.cpp b/src/srvcfg_manager.cpp
index 3a771d9..69f639d 100644
--- a/src/srvcfg_manager.cpp
+++ b/src/srvcfg_manager.cpp
@@ -224,8 +224,8 @@
void ServiceConfig::queryAndUpdateProperties()
{
- std::string objectPath = isSocketActivatedService ? socketObjectPath
- : serviceObjectPath;
+ std::string objectPath =
+ isSocketActivatedService ? socketObjectPath : serviceObjectPath;
if (objectPath.empty())
{
return;
@@ -235,60 +235,60 @@
[this](boost::system::error_code ec,
const boost::container::flat_map<std::string, VariantType>&
propertyMap) {
- if (ec)
- {
- lg2::error(
- "async_method_call error: Failed to service unit properties: {EC}",
- "EC", ec.value());
- return;
- }
- try
- {
- updateServiceProperties(propertyMap);
- if (!socketObjectPath.empty())
+ if (ec)
{
- conn->async_method_call(
- [this](boost::system::error_code ec,
- const boost::container::flat_map<
- std::string, VariantType>& propertyMap) {
- if (ec)
- {
- lg2::error(
- "async_method_call error: Failed to get all property: {EC}",
- "EC", ec.value());
- return;
- }
- try
- {
- updateSocketProperties(propertyMap);
- if (!srvCfgIface)
- {
- registerProperties();
- }
- }
- catch (const std::exception& e)
- {
- lg2::error(
- "Exception in getting socket properties: {ERROR}",
- "ERROR", e);
- return;
- }
- },
- sysdService, socketObjectPath, dBusPropIntf,
- dBusGetAllMethod, sysdSocketIntf);
+ lg2::error(
+ "async_method_call error: Failed to service unit properties: {EC}",
+ "EC", ec.value());
+ return;
}
- else if (!srvCfgIface)
+ try
{
- registerProperties();
+ updateServiceProperties(propertyMap);
+ if (!socketObjectPath.empty())
+ {
+ conn->async_method_call(
+ [this](boost::system::error_code ec,
+ const boost::container::flat_map<
+ std::string, VariantType>& propertyMap) {
+ if (ec)
+ {
+ lg2::error(
+ "async_method_call error: Failed to get all property: {EC}",
+ "EC", ec.value());
+ return;
+ }
+ try
+ {
+ updateSocketProperties(propertyMap);
+ if (!srvCfgIface)
+ {
+ registerProperties();
+ }
+ }
+ catch (const std::exception& e)
+ {
+ lg2::error(
+ "Exception in getting socket properties: {ERROR}",
+ "ERROR", e);
+ return;
+ }
+ },
+ sysdService, socketObjectPath, dBusPropIntf,
+ dBusGetAllMethod, sysdSocketIntf);
+ }
+ else if (!srvCfgIface)
+ {
+ registerProperties();
+ }
}
- }
- catch (const std::exception& e)
- {
- lg2::error("Exception in getting socket properties: {ERROR}",
- "ERROR", e);
- return;
- }
- },
+ catch (const std::exception& e)
+ {
+ lg2::error("Exception in getting socket properties: {ERROR}",
+ "ERROR", e);
+ return;
+ }
+ },
sysdService, objectPath, dBusPropIntf, dBusGetAllMethod, sysdUnitIntf);
return;
}
@@ -322,8 +322,7 @@
const std::string& objPath_, const std::string& baseUnitName_,
const std::string& instanceName_, const std::string& serviceObjPath_,
const std::string& socketObjPath_) :
- conn(conn_),
- server(srv_), objPath(objPath_), baseUnitName(baseUnitName_),
+ conn(conn_), server(srv_), objPath(objPath_), baseUnitName(baseUnitName_),
instanceName(instanceName_), serviceObjectPath(serviceObjPath_),
socketObjectPath(socketObjPath_)
{
@@ -504,28 +503,28 @@
updateInProgress = true;
boost::asio::spawn(conn->get_io_context(),
[this](boost::asio::yield_context yield) {
- // Stop and apply configuration for all objects
- for (auto& srvMgrObj : srvMgrObjects)
- {
- auto& srvObj = srvMgrObj.second;
- if (srvObj->updatedFlag)
- {
- srvObj->stopAndApplyUnitConfig(yield);
- }
- }
- // Do system reload
- systemdDaemonReload(conn, yield);
- // restart unit config.
- for (auto& srvMgrObj : srvMgrObjects)
- {
- auto& srvObj = srvMgrObj.second;
- if (srvObj->updatedFlag)
- {
- srvObj->restartUnitConfig(yield);
- }
- }
- updateInProgress = false;
- });
+ // Stop and apply configuration for all objects
+ for (auto& srvMgrObj : srvMgrObjects)
+ {
+ auto& srvObj = srvMgrObj.second;
+ if (srvObj->updatedFlag)
+ {
+ srvObj->stopAndApplyUnitConfig(yield);
+ }
+ }
+ // Do system reload
+ systemdDaemonReload(conn, yield);
+ // restart unit config.
+ for (auto& srvMgrObj : srvMgrObjects)
+ {
+ auto& srvObj = srvMgrObj.second;
+ if (srvObj->updatedFlag)
+ {
+ srvObj->restartUnitConfig(yield);
+ }
+ }
+ updateInProgress = false;
+ });
});
}
@@ -539,8 +538,50 @@
sockAttrIface->register_property(
sockAttrPropPort, portNum,
[this](const uint16_t& req, uint16_t& res) {
+ if (!internalSet)
+ {
+ if (req == res)
+ {
+ return 1;
+ }
+ if (updateInProgress)
+ {
+ return 0;
+ }
+ portNum = req;
+ updatedFlag |=
+ (1 << static_cast<uint8_t>(UpdatedProp::port));
+ startServiceRestartTimer();
+ }
+ res = req;
+ return 1;
+ });
+ }
+
+ srvCfgIface->register_property(
+ srvCfgPropMasked, unitMaskedState, [this](const bool& req, bool& res) {
if (!internalSet)
{
+#ifdef USB_CODE_UPDATE
+ if (baseUnitName == usbCodeUpdateUnitName)
+ {
+ unitMaskedState = req;
+ unitEnabledState = !unitMaskedState;
+ unitRunningState = !unitMaskedState;
+ internalSet = true;
+ srvCfgIface->set_property(srvCfgPropEnabled,
+ unitEnabledState);
+ srvCfgIface->set_property(srvCfgPropRunning,
+ unitRunningState);
+ srvCfgIface->set_property(srvCfgPropMasked,
+ unitMaskedState);
+ internalSet = false;
+ setUSBCodeUpdateState(unitEnabledState);
+ saveUSBCodeUpdateStateToFile(unitMaskedState,
+ unitEnabledState);
+ return 1;
+ }
+#endif
if (req == res)
{
return 1;
@@ -549,151 +590,122 @@
{
return 0;
}
- portNum = req;
- updatedFlag |= (1 << static_cast<uint8_t>(UpdatedProp::port));
+ unitMaskedState = req;
+ unitEnabledState = !unitMaskedState;
+ unitRunningState = !unitMaskedState;
+ updatedFlag |=
+ (1 << static_cast<uint8_t>(UpdatedProp::maskedState)) |
+ (1 << static_cast<uint8_t>(UpdatedProp::enabledState)) |
+ (1 << static_cast<uint8_t>(UpdatedProp::runningState));
+ internalSet = true;
+ srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
+ srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
+ internalSet = false;
startServiceRestartTimer();
}
res = req;
return 1;
});
- }
- srvCfgIface->register_property(srvCfgPropMasked, unitMaskedState,
- [this](const bool& req, bool& res) {
- if (!internalSet)
- {
-#ifdef USB_CODE_UPDATE
- if (baseUnitName == usbCodeUpdateUnitName)
+ srvCfgIface->register_property(
+ srvCfgPropEnabled, unitEnabledState,
+ [this](const bool& req, bool& res) {
+ if (!internalSet)
{
- unitMaskedState = req;
- unitEnabledState = !unitMaskedState;
- unitRunningState = !unitMaskedState;
- internalSet = true;
- srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
- srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
- srvCfgIface->set_property(srvCfgPropMasked, unitMaskedState);
- internalSet = false;
- setUSBCodeUpdateState(unitEnabledState);
- saveUSBCodeUpdateStateToFile(unitMaskedState, unitEnabledState);
- return 1;
- }
+#ifdef USB_CODE_UPDATE
+ if (baseUnitName == usbCodeUpdateUnitName)
+ {
+ if (unitMaskedState)
+ { // block updating if masked
+ lg2::error("Invalid value specified");
+ return -EINVAL;
+ }
+ unitEnabledState = req;
+ unitRunningState = req;
+ internalSet = true;
+ srvCfgIface->set_property(srvCfgPropEnabled,
+ unitEnabledState);
+ srvCfgIface->set_property(srvCfgPropRunning,
+ unitRunningState);
+ internalSet = false;
+ setUSBCodeUpdateState(unitEnabledState);
+ saveUSBCodeUpdateStateToFile(unitMaskedState,
+ unitEnabledState);
+ res = req;
+ return 1;
+ }
#endif
- if (req == res)
- {
- return 1;
- }
- if (updateInProgress)
- {
- return 0;
- }
- unitMaskedState = req;
- unitEnabledState = !unitMaskedState;
- unitRunningState = !unitMaskedState;
- updatedFlag |=
- (1 << static_cast<uint8_t>(UpdatedProp::maskedState)) |
- (1 << static_cast<uint8_t>(UpdatedProp::enabledState)) |
- (1 << static_cast<uint8_t>(UpdatedProp::runningState));
- internalSet = true;
- srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
- srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
- internalSet = false;
- startServiceRestartTimer();
- }
- res = req;
- return 1;
- });
-
- srvCfgIface->register_property(srvCfgPropEnabled, unitEnabledState,
- [this](const bool& req, bool& res) {
- if (!internalSet)
- {
-#ifdef USB_CODE_UPDATE
- if (baseUnitName == usbCodeUpdateUnitName)
- {
+ if (req == res)
+ {
+ return 1;
+ }
+ if (updateInProgress)
+ {
+ return 0;
+ }
if (unitMaskedState)
{ // block updating if masked
lg2::error("Invalid value specified");
return -EINVAL;
}
unitEnabledState = req;
- unitRunningState = req;
- internalSet = true;
- srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
- srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
- internalSet = false;
- setUSBCodeUpdateState(unitEnabledState);
- saveUSBCodeUpdateStateToFile(unitMaskedState, unitEnabledState);
- res = req;
- return 1;
+ updatedFlag |=
+ (1 << static_cast<uint8_t>(UpdatedProp::enabledState));
+ startServiceRestartTimer();
}
-#endif
- if (req == res)
- {
- return 1;
- }
- if (updateInProgress)
- {
- return 0;
- }
- if (unitMaskedState)
- { // block updating if masked
- lg2::error("Invalid value specified");
- return -EINVAL;
- }
- unitEnabledState = req;
- updatedFlag |= (1
- << static_cast<uint8_t>(UpdatedProp::enabledState));
- startServiceRestartTimer();
- }
- res = req;
- return 1;
- });
+ res = req;
+ return 1;
+ });
- srvCfgIface->register_property(srvCfgPropRunning, unitRunningState,
- [this](const bool& req, bool& res) {
- if (!internalSet)
- {
-#ifdef USB_CODE_UPDATE
- if (baseUnitName == usbCodeUpdateUnitName)
+ srvCfgIface->register_property(
+ srvCfgPropRunning, unitRunningState,
+ [this](const bool& req, bool& res) {
+ if (!internalSet)
{
+#ifdef USB_CODE_UPDATE
+ if (baseUnitName == usbCodeUpdateUnitName)
+ {
+ if (unitMaskedState)
+ { // block updating if masked
+ lg2::error("Invalid value specified");
+ return -EINVAL;
+ }
+ unitEnabledState = req;
+ unitRunningState = req;
+ internalSet = true;
+ srvCfgIface->set_property(srvCfgPropEnabled,
+ unitEnabledState);
+ srvCfgIface->set_property(srvCfgPropRunning,
+ unitRunningState);
+ internalSet = false;
+ setUSBCodeUpdateState(unitEnabledState);
+ saveUSBCodeUpdateStateToFile(unitMaskedState,
+ unitEnabledState);
+ res = req;
+ return 1;
+ }
+#endif
+ if (req == res)
+ {
+ return 1;
+ }
+ if (updateInProgress)
+ {
+ return 0;
+ }
if (unitMaskedState)
{ // block updating if masked
lg2::error("Invalid value specified");
return -EINVAL;
}
- unitEnabledState = req;
unitRunningState = req;
- internalSet = true;
- srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
- srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
- internalSet = false;
- setUSBCodeUpdateState(unitEnabledState);
- saveUSBCodeUpdateStateToFile(unitMaskedState, unitEnabledState);
- res = req;
- return 1;
+ updatedFlag |=
+ (1 << static_cast<uint8_t>(UpdatedProp::runningState));
+ startServiceRestartTimer();
}
-#endif
- if (req == res)
- {
- return 1;
- }
- if (updateInProgress)
- {
- return 0;
- }
- if (unitMaskedState)
- { // block updating if masked
- lg2::error("Invalid value specified");
- return -EINVAL;
- }
- unitRunningState = req;
- updatedFlag |= (1
- << static_cast<uint8_t>(UpdatedProp::runningState));
- startServiceRestartTimer();
- }
- res = req;
- return 1;
- });
+ res = req;
+ return 1;
+ });
srvCfgIface->initialize();
if (!socketObjectPath.empty())