clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: Ia4966a0790437eb0fc011c747f3be2a52884e4d8
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index 60ceb3c..4922cf6 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,19 +5,20 @@
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
-AlignOperands: true
-AlignTrailingComments: true
+AlignEscapedNewlines: Right
+AlignOperands: Align
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
+AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: true
+AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
@@ -30,20 +31,30 @@
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
+ AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
+BreakInheritanceList: AfterColon
+BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
+DeriveLineEnding: false
DerivePointerAlignment: false
+PointerAlignment: Left
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
@@ -51,21 +62,30 @@
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^[<"](gtest|gmock)'
- Priority: 5
+ Priority: 7
- Regex: '^"config.h"'
Priority: -1
- - Regex: '^".*\.hpp"'
+ - Regex: '^".*\.h"'
Priority: 1
- - Regex: '^<.*\.h>'
+ - Regex: '^".*\.hpp"'
Priority: 2
- - Regex: '^<.*'
+ - Regex: '^<.*\.h>'
Priority: 3
- - Regex: '.*'
+ - Regex: '^<.*\.hpp>'
Priority: 4
+ - Regex: '^<.*'
+ Priority: 5
+ - Regex: '.*'
+ Priority: 6
IndentCaseLabels: true
+IndentExternBlock: NoIndent
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -73,19 +93,29 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Left
+PenaltyIndentedWhitespace: 0
+QualifierAlignment: Left
+ReferenceAlignment: Left
ReflowComments: true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
@@ -93,7 +123,8 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
+
diff --git a/src/config_parser.cpp b/src/config_parser.cpp
index 25c4d11..afa563a 100644
--- a/src/config_parser.cpp
+++ b/src/config_parser.cpp
@@ -3,14 +3,15 @@
#include <fmt/compile.h>
#include <fmt/format.h>
-#include <functional>
-#include <iterator>
-#include <stdexcept>
#include <stdplus/exception.hpp>
#include <stdplus/fd/atomic.hpp>
#include <stdplus/fd/create.hpp>
#include <stdplus/fd/fmt.hpp>
#include <stdplus/fd/line.hpp>
+
+#include <functional>
+#include <iterator>
+#include <stdexcept>
#include <string>
#include <utility>
@@ -156,8 +157,7 @@
inline Parse(const fs::path& filename) :
filename(filename), section(nullptr), lineno(0)
- {
- }
+ {}
void pumpSection(std::string_view line)
{
@@ -264,8 +264,7 @@
}
}
catch (const stdplus::exception::Eof&)
- {
- }
+ {}
catch (const std::system_error& e)
{
fileExists = false;
diff --git a/src/config_parser.hpp b/src/config_parser.hpp
index 5df8d98..2d0bb1f 100644
--- a/src/config_parser.hpp
+++ b/src/config_parser.hpp
@@ -31,19 +31,16 @@
{
public:
struct unchecked
- {
- };
+ {};
template <typename... Args>
constexpr Checked(Args&&... args) : t(conCheck(std::forward<Args>(args)...))
- {
- }
+ {}
template <typename... Args>
constexpr Checked(unchecked, Args&&... args) :
t(std::forward<Args>(args)...)
- {
- }
+ {}
constexpr const T& get() const noexcept
{
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index 3465721..8843c7c 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -6,11 +6,12 @@
#include <sys/stat.h>
-#include <filesystem>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <filesystem>
+
namespace phosphor
{
namespace network
diff --git a/src/dns_updater.cpp b/src/dns_updater.cpp
index 5d9e417..d2c1a28 100644
--- a/src/dns_updater.cpp
+++ b/src/dns_updater.cpp
@@ -1,11 +1,12 @@
#include "dns_updater.hpp"
-#include <fstream>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <fstream>
+
namespace phosphor
{
namespace network
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index c5d6bdc..ef0355a 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -12,16 +12,17 @@
#include <linux/rtnetlink.h>
#include <net/if.h>
-#include <algorithm>
-#include <filesystem>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <stdplus/raw.hpp>
#include <stdplus/zstring.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
+#include <algorithm>
+#include <filesystem>
#include <string>
#include <unordered_map>
#include <variant>
-#include <xyz/openbmc_project/Common/error.hpp>
namespace phosphor
{
@@ -77,8 +78,7 @@
bool enabled) :
EthernetInterface(bus, manager, info, makeObjPath(objRoot, *info.intf.name),
config, enabled)
-{
-}
+{}
EthernetInterface::EthernetInterface(stdplus::PinnedRef<sdbusplus::bus_t> bus,
stdplus::PinnedRef<Manager> manager,
@@ -475,9 +475,9 @@
ServerList EthernetInterface::getNTPServerFromTimeSyncd()
{
ServerList servers; // Variable to capture the NTP Server IPs
- auto method =
- bus.get().new_method_call(TIMESYNCD_SERVICE, TIMESYNCD_SERVICE_PATH,
- PROPERTY_INTERFACE, METHOD_GET);
+ auto method = bus.get().new_method_call(TIMESYNCD_SERVICE,
+ TIMESYNCD_SERVICE_PATH,
+ PROPERTY_INTERFACE, METHOD_GET);
method.append(TIMESYNCD_INTERFACE, "LinkNTPServers");
@@ -734,8 +734,8 @@
dhcp["SendHostname"].emplace_back(conf.sendHostNameEnabled() ? "true"
: "false");
}
- auto path =
- config::pathForIntfConf(manager.get().getConfDir(), interfaceName());
+ auto path = config::pathForIntfConf(manager.get().getConfDir(),
+ interfaceName());
config.writeFile(path);
lg2::info("Wrote networkd file: {FILE_PATH}", "FILE_PATH", path);
}
diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp
index b66030a..87cfd68 100644
--- a/src/ethernet_interface.hpp
+++ b/src/ethernet_interface.hpp
@@ -5,19 +5,20 @@
#include "xyz/openbmc_project/Network/IP/Create/server.hpp"
#include "xyz/openbmc_project/Network/Neighbor/CreateStatic/server.hpp"
-#include <optional>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <stdplus/pinned.hpp>
#include <stdplus/zstring_view.hpp>
-#include <string>
-#include <vector>
#include <xyz/openbmc_project/Collection/DeleteAll/server.hpp>
#include <xyz/openbmc_project/Network/EthernetInterface/server.hpp>
#include <xyz/openbmc_project/Network/MACAddress/server.hpp>
#include <xyz/openbmc_project/Network/VLAN/server.hpp>
#include <xyz/openbmc_project/Object/Delete/server.hpp>
+#include <optional>
+#include <string>
+#include <vector>
+
namespace phosphor
{
namespace network
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp b/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
index c1e35d9..16d3d29 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
@@ -104,8 +104,8 @@
interfaces.emplace_back(biosMgrIntf);
auto depth = 0;
- auto mapperCall =
- bus.new_method_call(mapperBus, mapperObj, mapperIntf, "GetSubTree");
+ auto mapperCall = bus.new_method_call(mapperBus, mapperObj, mapperIntf,
+ "GetSubTree");
mapperCall.append(biosMgrObj, depth, interfaces);
@@ -137,7 +137,7 @@
{
// If there are more than 2 objects, object path must contain the
// interface name
- for (auto const& object : objectTree)
+ for (const auto& object : objectTree)
{
lg2::info("{INTERFACE_NAME}", "INTERFACE_NAME", biosMgrIntf);
lg2::info("{OBJECT}", "OBJECT", object.first);
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.hpp b/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.hpp
index 8c3e423..26f03f7 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.hpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.hpp
@@ -3,9 +3,10 @@
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
-#include <string>
#include <xyz/openbmc_project/Network/SystemConfiguration/server.hpp>
+#include <string>
+
namespace phosphor
{
namespace network
diff --git a/src/inventory_mac.cpp b/src/inventory_mac.cpp
index dfb03e5..e4aad88 100644
--- a/src/inventory_mac.cpp
+++ b/src/inventory_mac.cpp
@@ -5,17 +5,18 @@
#include "network_manager.hpp"
#include "types.hpp"
-#include <filesystem>
-#include <fstream>
-#include <memory>
#include <nlohmann/json.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
+#include <filesystem>
+#include <fstream>
+#include <memory>
#include <string>
#include <vector>
-#include <xyz/openbmc_project/Common/error.hpp>
namespace phosphor::network::inventory
{
@@ -83,8 +84,8 @@
auto depth = 0;
- auto mapperCall =
- bus.new_method_call(mapperBus, mapperObj, mapperIntf, "GetSubTree");
+ auto mapperCall = bus.new_method_call(mapperBus, mapperObj, mapperIntf,
+ "GetSubTree");
mapperCall.append(invRoot, depth, interfaces);
@@ -117,7 +118,7 @@
{
// If there are more than 2 objects, object path must contain the
// interface name
- for (auto const& object : objectTree)
+ for (const auto& object : objectTree)
{
lg2::info("Get info on interface {INTERFACE_NAME}, object {OBJECT}",
"INTERFACE_NAME", interfaceName, "OBJECT", object.first);
diff --git a/src/inventory_mac.hpp b/src/inventory_mac.hpp
index 1b6aa8b..ee97df6 100644
--- a/src/inventory_mac.hpp
+++ b/src/inventory_mac.hpp
@@ -1,8 +1,9 @@
#pragma once
-#include <memory>
#include <sdbusplus/bus.hpp>
#include <stdplus/pinned.hpp>
+#include <memory>
+
namespace phosphor::network
{
diff --git a/src/ipaddress.cpp b/src/ipaddress.cpp
index 2235550..464a2c0 100644
--- a/src/ipaddress.cpp
+++ b/src/ipaddress.cpp
@@ -6,10 +6,11 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
#include <stdexcept>
#include <string>
#include <string_view>
-#include <xyz/openbmc_project/Common/error.hpp>
namespace phosphor
{
@@ -30,8 +31,7 @@
template <typename T>
struct Proto
-{
-};
+{};
template <>
struct Proto<in_addr>
@@ -49,8 +49,7 @@
stdplus::PinnedRef<EthernetInterface> parent, IfAddr addr,
AddressOrigin origin) :
IPAddress(bus, makeObjPath(objRoot, addr), parent, addr, origin)
-{
-}
+{}
IPAddress::IPAddress(sdbusplus::bus_t& bus,
sdbusplus::message::object_path objPath,
diff --git a/src/ipaddress.hpp b/src/ipaddress.hpp
index 743025b..1785e06 100644
--- a/src/ipaddress.hpp
+++ b/src/ipaddress.hpp
@@ -5,10 +5,11 @@
#include <sdbusplus/message/native_types.hpp>
#include <sdbusplus/server/object.hpp>
#include <stdplus/pinned.hpp>
-#include <string_view>
#include <xyz/openbmc_project/Network/IP/server.hpp>
#include <xyz/openbmc_project/Object/Delete/server.hpp>
+#include <string_view>
+
namespace phosphor
{
namespace network
diff --git a/src/ncsi_netlink_main.cpp b/src/ncsi_netlink_main.cpp
index c437695..5f65777 100644
--- a/src/ncsi_netlink_main.cpp
+++ b/src/ncsi_netlink_main.cpp
@@ -17,6 +17,7 @@
#include "ncsi_util.hpp"
#include <phosphor-logging/lg2.hpp>
+
#include <string>
#include <vector>
diff --git a/src/ncsi_util.cpp b/src/ncsi_util.cpp
index 07ac7aa..70e934b 100644
--- a/src/ncsi_util.cpp
+++ b/src/ncsi_util.cpp
@@ -6,9 +6,10 @@
#include <netlink/genl/genl.h>
#include <netlink/netlink.h>
+#include <phosphor-logging/lg2.hpp>
+
#include <iomanip>
#include <iostream>
-#include <phosphor-logging/lg2.hpp>
#include <vector>
namespace phosphor
@@ -49,8 +50,7 @@
std::span<const unsigned char> p = std::span<const unsigned char>()) :
cmd(c),
ncsi_cmd(nc), payload(p)
- {
- }
+ {}
int cmd;
int ncsi_cmd;
@@ -187,7 +187,6 @@
}
if (channeltb[NCSI_CHANNEL_ATTR_LINK_STATE])
{
-
auto link =
nla_get_u32(channeltb[NCSI_CHANNEL_ATTR_LINK_STATE]);
lg2::debug("Channel Link State : {LINK_STATE}", "LINK_STATE",
@@ -237,8 +236,8 @@
}
auto data_len = nla_len(tb[NCSI_ATTR_DATA]) - sizeof(NCSIPacketHeader);
- unsigned char* data =
- (unsigned char*)nla_data(tb[NCSI_ATTR_DATA]) + sizeof(NCSIPacketHeader);
+ unsigned char* data = (unsigned char*)nla_data(tb[NCSI_ATTR_DATA]) +
+ sizeof(NCSIPacketHeader);
auto s = std::span<const unsigned char>(data, data_len);
// Dump the response to stdout. Enhancement: option to save response data
diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index 959f524..d9f2436 100644
--- a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -5,9 +5,10 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
-#include <string>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <string>
+
namespace phosphor
{
namespace network
@@ -24,8 +25,7 @@
stdplus::PinnedRef<EthernetInterface> parent, InAddrAny addr,
ether_addr lladdr, State state) :
Neighbor(bus, makeObjPath(objRoot, addr), parent, addr, lladdr, state)
-{
-}
+{}
Neighbor::Neighbor(sdbusplus::bus_t& bus,
sdbusplus::message::object_path objPath,
diff --git a/src/neighbor.hpp b/src/neighbor.hpp
index 861a1ec..f36371a 100644
--- a/src/neighbor.hpp
+++ b/src/neighbor.hpp
@@ -5,10 +5,11 @@
#include <sdbusplus/message/native_types.hpp>
#include <sdbusplus/server/object.hpp>
#include <stdplus/pinned.hpp>
-#include <string_view>
#include <xyz/openbmc_project/Network/Neighbor/server.hpp>
#include <xyz/openbmc_project/Object/Delete/server.hpp>
+#include <string_view>
+
namespace phosphor
{
namespace network
diff --git a/src/netlink.cpp b/src/netlink.cpp
index 1577161..69ea5c6 100644
--- a/src/netlink.cpp
+++ b/src/netlink.cpp
@@ -4,11 +4,12 @@
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
-#include <array>
-#include <stdexcept>
#include <stdplus/fd/create.hpp>
#include <stdplus/fd/ops.hpp>
#include <stdplus/raw.hpp>
+
+#include <array>
+#include <stdexcept>
#include <system_error>
using stdplus::raw::Aligned;
diff --git a/src/netlink.hpp b/src/netlink.hpp
index be44d24..b6b89d9 100644
--- a/src/netlink.hpp
+++ b/src/netlink.hpp
@@ -4,6 +4,7 @@
#include <function2/function2.hpp>
#include <stdplus/raw.hpp>
+
#include <string_view>
#include <tuple>
#include <type_traits>
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index ffcae48..72e0d03 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -10,13 +10,14 @@
#include <linux/neighbour.h>
#include <net/if.h>
-#include <filesystem>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/message.hpp>
#include <stdplus/pinned.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <filesystem>
+
constexpr char SYSTEMD_BUSNAME[] = "org.freedesktop.systemd1";
constexpr char SYSTEMD_PATH[] = "/org/freedesktop/systemd1";
constexpr char SYSTEMD_INTERFACE[] = "org.freedesktop.systemd1.Manager";
@@ -48,31 +49,31 @@
systemdNetworkdEnabledMatch(
bus, enabledMatch,
[man = stdplus::PinnedRef(*this)](sdbusplus::message_t& m) {
- std::string intf;
- std::unordered_map<std::string, std::variant<std::string>> values;
- try
- {
- m.read(intf, values);
- auto it = values.find("AdministrativeState");
- if (it == values.end())
- {
- return;
- }
- const std::string_view obj = m.get_path();
- auto sep = obj.rfind('/');
- if (sep == obj.npos || sep + 3 > obj.size())
- {
- throw std::invalid_argument("Invalid obj path");
- }
- auto ifidx = DecodeInt<unsigned, 10>{}(obj.substr(sep + 3));
- const auto& state = std::get<std::string>(it->second);
- man.get().handleAdminState(state, ifidx);
- }
- catch (const std::exception& e)
- {
- lg2::error("AdministrativeState match parsing failed: {ERROR}",
- "ERROR", e);
- }
+ std::string intf;
+ std::unordered_map<std::string, std::variant<std::string>> values;
+ try
+ {
+ m.read(intf, values);
+ auto it = values.find("AdministrativeState");
+ if (it == values.end())
+ {
+ return;
+ }
+ const std::string_view obj = m.get_path();
+ auto sep = obj.rfind('/');
+ if (sep == obj.npos || sep + 3 > obj.size())
+ {
+ throw std::invalid_argument("Invalid obj path");
+ }
+ auto ifidx = DecodeInt<unsigned, 10>{}(obj.substr(sep + 3));
+ const auto& state = std::get<std::string>(it->second);
+ man.get().handleAdminState(state, ifidx);
+ }
+ catch (const std::exception& e)
+ {
+ lg2::error("AdministrativeState match parsing failed: {ERROR}", "ERROR",
+ e);
+ }
})
{
reload.setCallback([&]() {
@@ -360,38 +361,38 @@
{
std::visit(
[&](auto addr) {
- if constexpr (std::is_same_v<in_addr, decltype(addr)>)
- {
- it->second.defgw4.emplace(addr);
- }
- else if constexpr (std::is_same_v<in6_addr, decltype(addr)>)
- {
- it->second.defgw6.emplace(addr);
- }
- else
- {
- static_assert(!std::is_same_v<void, decltype(addr)>);
- }
+ if constexpr (std::is_same_v<in_addr, decltype(addr)>)
+ {
+ it->second.defgw4.emplace(addr);
+ }
+ else if constexpr (std::is_same_v<in6_addr, decltype(addr)>)
+ {
+ it->second.defgw6.emplace(addr);
+ }
+ else
+ {
+ static_assert(!std::is_same_v<void, decltype(addr)>);
+ }
},
addr);
if (auto it = interfacesByIdx.find(ifidx); it != interfacesByIdx.end())
{
std::visit(
[&](auto addr) {
- if constexpr (std::is_same_v<in_addr, decltype(addr)>)
- {
- it->second->EthernetInterfaceIntf::defaultGateway(
- std::to_string(addr));
- }
- else if constexpr (std::is_same_v<in6_addr, decltype(addr)>)
- {
- it->second->EthernetInterfaceIntf::defaultGateway6(
- std::to_string(addr));
- }
- else
- {
- static_assert(!std::is_same_v<void, decltype(addr)>);
- }
+ if constexpr (std::is_same_v<in_addr, decltype(addr)>)
+ {
+ it->second->EthernetInterfaceIntf::defaultGateway(
+ std::to_string(addr));
+ }
+ else if constexpr (std::is_same_v<in6_addr, decltype(addr)>)
+ {
+ it->second->EthernetInterfaceIntf::defaultGateway6(
+ std::to_string(addr));
+ }
+ else
+ {
+ static_assert(!std::is_same_v<void, decltype(addr)>);
+ }
},
addr);
}
@@ -408,52 +409,48 @@
{
std::visit(
[&](auto addr) {
- if constexpr (std::is_same_v<in_addr, decltype(addr)>)
+ if constexpr (std::is_same_v<in_addr, decltype(addr)>)
+ {
+ if (it->second.defgw4 == addr)
{
- if (it->second.defgw4 == addr)
- {
- it->second.defgw4.reset();
- }
+ it->second.defgw4.reset();
}
- else if constexpr (std::is_same_v<in6_addr, decltype(addr)>)
+ }
+ else if constexpr (std::is_same_v<in6_addr, decltype(addr)>)
+ {
+ if (it->second.defgw6 == addr)
{
- if (it->second.defgw6 == addr)
- {
- it->second.defgw6.reset();
- }
+ it->second.defgw6.reset();
}
- else
- {
- static_assert(!std::is_same_v<void, decltype(addr)>);
- }
+ }
+ else
+ {
+ static_assert(!std::is_same_v<void, decltype(addr)>);
+ }
},
addr);
if (auto it = interfacesByIdx.find(ifidx); it != interfacesByIdx.end())
{
std::visit(
[&](auto addr) {
- if constexpr (std::is_same_v<in_addr, decltype(addr)>)
+ if constexpr (std::is_same_v<in_addr, decltype(addr)>)
+ {
+ if (it->second->defaultGateway() == std::to_string(addr))
{
- if (it->second->defaultGateway() ==
- std::to_string(addr))
- {
- it->second->EthernetInterfaceIntf::defaultGateway(
- "");
- }
+ it->second->EthernetInterfaceIntf::defaultGateway("");
}
- else if constexpr (std::is_same_v<in6_addr, decltype(addr)>)
+ }
+ else if constexpr (std::is_same_v<in6_addr, decltype(addr)>)
+ {
+ if (it->second->defaultGateway6() == std::to_string(addr))
{
- if (it->second->defaultGateway6() ==
- std::to_string(addr))
- {
- it->second->EthernetInterfaceIntf::defaultGateway6(
- "");
- }
+ it->second->EthernetInterfaceIntf::defaultGateway6("");
}
- else
- {
- static_assert(!std::is_same_v<void, decltype(addr)>);
- }
+ }
+ else
+ {
+ static_assert(!std::is_same_v<void, decltype(addr)>);
+ }
},
addr);
}
diff --git a/src/network_manager.hpp b/src/network_manager.hpp
index 490c4bc..2643d52 100644
--- a/src/network_manager.hpp
+++ b/src/network_manager.hpp
@@ -5,18 +5,19 @@
#include "types.hpp"
#include "xyz/openbmc_project/Network/VLAN/Create/server.hpp"
-#include <filesystem>
#include <function2/function2.hpp>
-#include <memory>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
#include <sdbusplus/message/native_types.hpp>
#include <stdplus/pinned.hpp>
#include <stdplus/zstring_view.hpp>
+#include <xyz/openbmc_project/Common/FactoryReset/server.hpp>
+
+#include <filesystem>
+#include <memory>
#include <string>
#include <string_view>
#include <vector>
-#include <xyz/openbmc_project/Common/FactoryReset/server.hpp>
namespace phosphor
{
diff --git a/src/network_manager_main.cpp b/src/network_manager_main.cpp
index 3669429..ca971f3 100644
--- a/src/network_manager_main.cpp
+++ b/src/network_manager_main.cpp
@@ -9,7 +9,6 @@
#include <fmt/format.h>
-#include <chrono>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/manager.hpp>
@@ -21,6 +20,8 @@
#include <stdplus/pinned.hpp>
#include <stdplus/signal.hpp>
+#include <chrono>
+
constexpr char DEFAULT_OBJPATH[] = "/xyz/openbmc_project/network";
namespace phosphor::network
@@ -34,8 +35,7 @@
public:
TimerExecutor(sdeventplus::Event& event, std::chrono::seconds delay) :
delay(delay), timer(event, nullptr)
- {
- }
+ {}
void schedule() override
{
diff --git a/src/rtnetlink_server.hpp b/src/rtnetlink_server.hpp
index 49e32ea..7e06494 100644
--- a/src/rtnetlink_server.hpp
+++ b/src/rtnetlink_server.hpp
@@ -20,7 +20,6 @@
*/
class Server
{
-
public:
/** @brief Constructor
*
diff --git a/src/system_configuration.cpp b/src/system_configuration.cpp
index f817dfe..7604eb9 100644
--- a/src/system_configuration.cpp
+++ b/src/system_configuration.cpp
@@ -25,35 +25,33 @@
SystemConfiguration::SystemConfiguration(
stdplus::PinnedRef<sdbusplus::bus_t> bus, stdplus::const_zstring objPath) :
Iface(bus, objPath.c_str(), Iface::action::defer_emit),
- bus(bus),
- hostnamePropMatch(
- bus, propMatch,
- [sc = stdplus::PinnedRef(*this)](sdbusplus::message_t& m) {
- std::string intf;
- std::unordered_map<std::string, std::variant<std::string>> values;
- try
- {
- m.read(intf, values);
- auto it = values.find("Hostname");
- if (it == values.end())
- {
- return;
- }
- sc.get().Iface::hostName(std::get<std::string>(it->second));
- }
- catch (const std::exception& e)
- {
- lg2::error("Hostname match parsing failed: {ERROR}", "ERROR",
- e);
- }
- })
+ bus(bus), hostnamePropMatch(
+ bus, propMatch,
+ [sc = stdplus::PinnedRef(*this)](sdbusplus::message_t& m) {
+ std::string intf;
+ std::unordered_map<std::string, std::variant<std::string>> values;
+ try
+ {
+ m.read(intf, values);
+ auto it = values.find("Hostname");
+ if (it == values.end())
+ {
+ return;
+ }
+ sc.get().Iface::hostName(std::get<std::string>(it->second));
+ }
+ catch (const std::exception& e)
+ {
+ lg2::error("Hostname match parsing failed: {ERROR}", "ERROR", e);
+ }
+ })
{
try
{
std::variant<std::string> name;
- auto req =
- bus.get().new_method_call(HOSTNAMED_SVC, HOSTNAMED_OBJ,
- "org.freedesktop.DBus.Properties", "Get");
+ auto req = bus.get().new_method_call(HOSTNAMED_SVC, HOSTNAMED_OBJ,
+ "org.freedesktop.DBus.Properties",
+ "Get");
req.append(HOSTNAMED_INTF, "Hostname");
auto reply = req.call();
diff --git a/src/system_configuration.hpp b/src/system_configuration.hpp
index 4eceec0..8f79bac 100644
--- a/src/system_configuration.hpp
+++ b/src/system_configuration.hpp
@@ -5,9 +5,10 @@
#include <sdbusplus/server/object.hpp>
#include <stdplus/pinned.hpp>
#include <stdplus/zstring.hpp>
-#include <string>
#include <xyz/openbmc_project/Network/SystemConfiguration/server.hpp>
+#include <string>
+
namespace phosphor
{
namespace network
diff --git a/src/system_queries.cpp b/src/system_queries.cpp
index 6c59547..56feb8d 100644
--- a/src/system_queries.cpp
+++ b/src/system_queries.cpp
@@ -8,12 +8,13 @@
#include <linux/sockios.h>
#include <net/if.h>
-#include <algorithm>
-#include <optional>
#include <phosphor-logging/lg2.hpp>
-#include <stdexcept>
#include <stdplus/fd/create.hpp>
#include <stdplus/util/cexec.hpp>
+
+#include <algorithm>
+#include <optional>
+#include <stdexcept>
#include <string_view>
namespace phosphor::network::system
@@ -24,8 +25,8 @@
static stdplus::Fd& getIFSock()
{
using namespace stdplus::fd;
- static auto fd =
- socket(SocketDomain::INet, SocketType::Datagram, SocketProto::IP);
+ static auto fd = socket(SocketDomain::INet, SocketType::Datagram,
+ SocketProto::IP);
return fd;
}
@@ -85,8 +86,7 @@
return optionalIFReq(
ifname, SIOCETHTOOL, "ETHTOOL"sv,
[&](const ifreq&) {
- return EthInfo{.autoneg = edata.autoneg != 0,
- .speed = edata.speed};
+ return EthInfo{.autoneg = edata.autoneg != 0, .speed = edata.speed};
},
&edata)
.value_or(EthInfo{});
@@ -116,17 +116,16 @@
ifinfomsg msg = {};
msg.ifi_family = AF_UNSPEC;
msg.ifi_index = idx;
- netlink::performRequest(
- NETLINK_ROUTE, RTM_DELLINK, NLM_F_REPLACE, msg,
- [&](const nlmsghdr& hdr, std::string_view data) {
- int err = 0;
- if (hdr.nlmsg_type == NLMSG_ERROR)
- {
- err = netlink::extractRtData<nlmsgerr>(data).error;
- }
- throw std::runtime_error(
- fmt::format("Failed to delete `{}`: {}", idx, strerror(err)));
- });
+ netlink::performRequest(NETLINK_ROUTE, RTM_DELLINK, NLM_F_REPLACE, msg,
+ [&](const nlmsghdr& hdr, std::string_view data) {
+ int err = 0;
+ if (hdr.nlmsg_type == NLMSG_ERROR)
+ {
+ err = netlink::extractRtData<nlmsgerr>(data).error;
+ }
+ throw std::runtime_error(
+ fmt::format("Failed to delete `{}`: {}", idx, strerror(err)));
+ });
}
} // namespace phosphor::network::system
diff --git a/src/system_queries.hpp b/src/system_queries.hpp
index 9027cb3..5b54985 100644
--- a/src/system_queries.hpp
+++ b/src/system_queries.hpp
@@ -1,8 +1,9 @@
#pragma once
#include "types.hpp"
-#include <cstdint>
#include <stdplus/zstring_view.hpp>
+
+#include <cstdint>
#include <string_view>
namespace phosphor::network::system
diff --git a/src/types.hpp b/src/types.hpp
index 8d1daf4..ba4ee1a 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -46,18 +46,16 @@
static void invalidPfx(uint8_t pfx);
public:
- constexpr IfAddr() : addr({}), pfx(0)
- {
- }
+ constexpr IfAddr() : addr({}), pfx(0) {}
constexpr IfAddr(InAddrAny addr, uint8_t pfx) : addr(addr), pfx(pfx)
{
std::visit(
[pfx](auto v) {
- if (sizeof(v) * 8 < pfx)
- {
- invalidPfx(pfx);
- }
+ if (sizeof(v) * 8 < pfx)
+ {
+ invalidPfx(pfx);
+ }
},
addr);
}
@@ -285,38 +283,38 @@
throw std::invalid_argument("Empty Str");
}
constexpr auto max = std::numeric_limits<T>::max();
- auto ret =
- std::accumulate(str.begin(), str.end(), T{}, [&](T r, char c) {
- auto v = detail::charLookup[c];
- if (v < 0 || v >= base)
+ auto ret = std::accumulate(str.begin(), str.end(), T{},
+ [&](T r, char c) {
+ auto v = detail::charLookup[c];
+ if (v < 0 || v >= base)
+ {
+ throw std::invalid_argument("Invalid numeral");
+ }
+ if constexpr (std::popcount(base) == 1)
+ {
+ constexpr auto shift = std::countr_zero(base);
+ constexpr auto maxshift = max >> shift;
+ if (r > maxshift)
{
- throw std::invalid_argument("Invalid numeral");
+ throw std::overflow_error("Integer Decode");
}
- if constexpr (std::popcount(base) == 1)
+ return (r << shift) | v;
+ }
+ else
+ {
+ constexpr auto maxbase = max / base;
+ if (r > maxbase)
{
- constexpr auto shift = std::countr_zero(base);
- constexpr auto maxshift = max >> shift;
- if (r > maxshift)
- {
- throw std::overflow_error("Integer Decode");
- }
- return (r << shift) | v;
+ throw std::overflow_error("Integer Decode");
}
- else
+ r *= base;
+ if (max - v < r)
{
- constexpr auto maxbase = max / base;
- if (r > maxbase)
- {
- throw std::overflow_error("Integer Decode");
- }
- r *= base;
- if (max - v < r)
- {
- throw std::overflow_error("Integer Decode");
- }
- return r + v;
+ throw std::overflow_error("Integer Decode");
}
- });
+ return r + v;
+ }
+ });
return ret;
}
};
@@ -376,8 +374,7 @@
template <typename T>
struct ToAddr
-{
-};
+{};
template <>
struct ToAddr<ether_addr>
@@ -524,8 +521,7 @@
template <typename T>
struct ToStr
-{
-};
+{};
template <>
struct ToStr<char>
@@ -698,14 +694,14 @@
{
return std::visit(
[t](auto v) {
- if constexpr (std::is_same_v<T, decltype(v)>)
- {
- return v == t;
- }
- else
- {
- return false;
- }
+ if constexpr (std::is_same_v<T, decltype(v)>)
+ {
+ return v == t;
+ }
+ else
+ {
+ return false;
+ }
},
v);
}
@@ -777,26 +773,21 @@
{
template <>
struct formatter<ether_addr> : phosphor::network::detail::Format<ether_addr>
-{
-};
+{};
template <>
struct formatter<in_addr> : phosphor::network::detail::Format<in_addr>
-{
-};
+{};
template <>
struct formatter<in6_addr> : phosphor::network::detail::Format<in6_addr>
-{
-};
+{};
template <>
-struct formatter<phosphor::network::InAddrAny>
- : phosphor::network::detail::Format<phosphor::network::InAddrAny>
-{
-};
+struct formatter<phosphor::network::InAddrAny> :
+ phosphor::network::detail::Format<phosphor::network::InAddrAny>
+{};
template <>
-struct formatter<phosphor::network::IfAddr>
- : phosphor::network::detail::Format<phosphor::network::IfAddr>
-{
-};
+struct formatter<phosphor::network::IfAddr> :
+ phosphor::network::detail::Format<phosphor::network::IfAddr>
+{};
} // namespace fmt
namespace std
diff --git a/src/util.cpp b/src/util.cpp
index 0b9c1e2..87fe235 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -9,12 +9,13 @@
#include <fmt/format.h>
#include <sys/wait.h>
-#include <cctype>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
+#include <cctype>
#include <string>
#include <string_view>
-#include <xyz/openbmc_project/Common/error.hpp>
namespace phosphor
{
@@ -168,8 +169,7 @@
auto&& fun)
{
if (!config.getFileExists())
- {
- }
+ {}
else if (auto str = config.map.getLastValueString(section, key);
str == nullptr)
{
diff --git a/src/util.hpp b/src/util.hpp
index 90beca2..f35e512 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -1,9 +1,10 @@
#pragma once
#include "types.hpp"
-#include <optional>
#include <stdplus/raw.hpp>
#include <stdplus/zstring.hpp>
+
+#include <optional>
#include <string>
#include <string_view>
#include <unordered_set>
diff --git a/test/ibm/hypervisor-network-mgr-test/mock_hyp_sys_config.hpp b/test/ibm/hypervisor-network-mgr-test/mock_hyp_sys_config.hpp
index 1f5b6e6..f44de21 100644
--- a/test/ibm/hypervisor-network-mgr-test/mock_hyp_sys_config.hpp
+++ b/test/ibm/hypervisor-network-mgr-test/mock_hyp_sys_config.hpp
@@ -17,8 +17,7 @@
MockHypSysConfig(sdbusplus::bus_t& bus, const std::string& objPath,
HypNetworkMgr& parent) :
HypSysConfig(bus, objPath, parent)
- {
- }
+ {}
void setHostname(std::string hn)
{
diff --git a/test/mock_ethernet_interface.hpp b/test/mock_ethernet_interface.hpp
index 91e9bf5..8c12926 100644
--- a/test/mock_ethernet_interface.hpp
+++ b/test/mock_ethernet_interface.hpp
@@ -13,8 +13,7 @@
template <typename... Args>
MockEthernetInterface(Args&&... args) :
EthernetInterface(std::forward<Args>(args)..., /*nicEnabled=*/true)
- {
- }
+ {}
MOCK_METHOD((ServerList), getNTPServerFromTimeSyncd, (), (override));
MOCK_METHOD((ServerList), getNameServerFromResolvd, (), (override));
diff --git a/test/mock_syscall.cpp b/test/mock_syscall.cpp
index 0699ceb..fa2ae2d 100644
--- a/test/mock_syscall.cpp
+++ b/test/mock_syscall.cpp
@@ -14,13 +14,14 @@
#include <sys/types.h>
#include <unistd.h>
+#include <stdplus/raw.hpp>
+
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <stdexcept>
-#include <stdplus/raw.hpp>
#include <string>
#include <string_view>
#include <vector>
@@ -151,8 +152,8 @@
return in.size();
}
-extern "C" {
-
+extern "C"
+{
int ioctl(int fd, unsigned long int request, ...)
{
va_list vl;
diff --git a/test/test_config_parser.cpp b/test/test_config_parser.cpp
index e742cdf..2948c73 100644
--- a/test/test_config_parser.cpp
+++ b/test/test_config_parser.cpp
@@ -4,15 +4,16 @@
#include <fmt/compile.h>
#include <fmt/format.h>
-#include <exception>
-#include <fstream>
#include <phosphor-logging/elog-errors.hpp>
-#include <stdexcept>
#include <stdplus/fd/atomic.hpp>
#include <stdplus/fd/fmt.hpp>
#include <stdplus/gtest/tmp.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <exception>
+#include <fstream>
+#include <stdexcept>
+
#include <gmock/gmock.h>
#include <gtest/gtest.h>
diff --git a/test/test_ethernet_interface.cpp b/test/test_ethernet_interface.cpp
index 884224b..7b72166 100644
--- a/test/test_ethernet_interface.cpp
+++ b/test/test_ethernet_interface.cpp
@@ -7,9 +7,10 @@
#include <sdbusplus/bus.hpp>
#include <stdplus/gtest/tmp.hpp>
-#include <string_view>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <string_view>
+
#include <gtest/gtest.h>
namespace phosphor
@@ -33,8 +34,7 @@
manager(bus, "/xyz/openbmc_test/network", confDir),
interface(makeInterface(bus, manager))
- {
- }
+ {}
static MockEthernetInterface
makeInterface(stdplus::PinnedRef<sdbusplus::bus_t> bus,
diff --git a/test/test_netlink.cpp b/test/test_netlink.cpp
index c6f7983..4514fa4 100644
--- a/test/test_netlink.cpp
+++ b/test/test_netlink.cpp
@@ -5,9 +5,10 @@
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+#include <stdplus/raw.hpp>
+
#include <cstring>
#include <stdexcept>
-#include <stdplus/raw.hpp>
#include <string_view>
#include <gtest/gtest.h>
diff --git a/test/test_network_manager.cpp b/test/test_network_manager.cpp
index 7e39665..03d2944 100644
--- a/test/test_network_manager.cpp
+++ b/test/test_network_manager.cpp
@@ -2,10 +2,11 @@
#include "config_parser.hpp"
-#include <filesystem>
#include <sdbusplus/bus.hpp>
#include <stdplus/gtest/tmp.hpp>
+#include <filesystem>
+
#include <gtest/gtest.h>
namespace phosphor
@@ -24,8 +25,7 @@
TestNetworkManager() :
bus(sdbusplus::bus::new_default()),
manager(bus, "/xyz/openbmc_test/abc", CaseTmpDir())
- {
- }
+ {}
void deleteVLAN(std::string_view ifname)
{
diff --git a/test/test_network_manager.hpp b/test/test_network_manager.hpp
index 68d5088..a9a7985 100644
--- a/test/test_network_manager.hpp
+++ b/test/test_network_manager.hpp
@@ -11,7 +11,7 @@
struct MockExecutor : DelayedExecutor
{
MOCK_METHOD((void), schedule, (), (override));
- MOCK_METHOD((void), setCallback, (fu2::unique_function<void()> &&),
+ MOCK_METHOD((void), setCallback, (fu2::unique_function<void()>&&),
(override));
};
@@ -36,8 +36,7 @@
stdplus::zstring_view path,
const std::filesystem::path& dir) :
Manager(bus, reloadForManager(), path, dir)
- {
- }
+ {}
using Manager::handleAdminState;
};
diff --git a/test/test_util.cpp b/test/test_util.cpp
index 9e1b4d0..7d4c611 100644
--- a/test/test_util.cpp
+++ b/test/test_util.cpp
@@ -1,7 +1,8 @@
#include "util.hpp"
-#include <stdexcept>
#include <stdplus/raw.hpp>
+
+#include <stdexcept>
#include <string>
#include <string_view>