clang-format-11: reformat
The .clang-format file here is an old version of the common one.
Upgrade to the latest and reformat.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ic87853e6004d2d5ad6645a3ece8c0c87ccc96efd
diff --git a/.clang-format b/.clang-format
index bbc1bb1..52ac0a1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,7 +5,7 @@
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
+AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
@@ -14,13 +14,13 @@
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: false
+AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
+ AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
@@ -29,25 +29,50 @@
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
+ AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
+BreakInheritanceList: AfterColon
+BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
-DerivePointerAlignment: true
+DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IncludeCategories:
+ - Regex: '^[<"](gtest|gmock)'
+ Priority: 7
+ - Regex: '^"config.h"'
+ Priority: -1
+ - Regex: '^".*\.h"'
+ Priority: 1
+ - Regex: '^".*\.hpp"'
+ Priority: 2
+ - Regex: '^<.*\.h>'
+ Priority: 3
+ - Regex: '^<.*\.hpp>'
+ Priority: 4
+ - Regex: '^<.*'
+ Priority: 5
+ - Regex: '.*'
+ Priority: 6
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
@@ -65,12 +90,17 @@
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Right
ReflowComments: true
-SortIncludes: false
+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
@@ -78,7 +108,7 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
diff --git a/snmp.hpp b/snmp.hpp
index a076054..2479c24 100644
--- a/snmp.hpp
+++ b/snmp.hpp
@@ -14,7 +14,8 @@
* @param[in] tArgs - arguments for the trap.
*/
-template <typename T, typename... ArgTypes> void sendTrap(ArgTypes&&... tArgs)
+template <typename T, typename... ArgTypes>
+void sendTrap(ArgTypes&&... tArgs)
{
T obj(std::forward<ArgTypes>(tArgs)...);
obj.sendTrap();
diff --git a/snmp_client.cpp b/snmp_client.cpp
index 52eb744..3f6a405 100644
--- a/snmp_client.cpp
+++ b/snmp_client.cpp
@@ -1,4 +1,5 @@
#include "snmp_client.hpp"
+
#include "snmp_conf_manager.hpp"
#include "snmp_serialize.hpp"
diff --git a/snmp_client.hpp b/snmp_client.hpp
index 51ebabb..b5b0eb2 100644
--- a/snmp_client.hpp
+++ b/snmp_client.hpp
@@ -1,12 +1,11 @@
#pragma once
-#include <experimental/filesystem>
-
#include "xyz/openbmc_project/Network/Client/server.hpp"
#include "xyz/openbmc_project/Object/Delete/server.hpp"
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
+#include <experimental/filesystem>
#include <string>
namespace phosphor
@@ -33,10 +32,10 @@
{
public:
Client() = delete;
- Client(const Client &) = delete;
- Client &operator=(const Client &) = delete;
- Client(Client &&) = delete;
- Client &operator=(Client &&) = delete;
+ Client(const Client&) = delete;
+ Client& operator=(const Client&) = delete;
+ Client(Client&&) = delete;
+ Client& operator=(Client&&) = delete;
virtual ~Client() = default;
/** @brief Constructor to put object onto bus at a dbus path.
@@ -46,20 +45,19 @@
* @param[in] address - IPaddress/Hostname.
* @param[in] port - network port.
*/
- Client(sdbusplus::bus::bus &bus, const char *objPath, ConfManager &parent,
- const std::string &address, uint16_t port);
+ Client(sdbusplus::bus::bus& bus, const char* objPath, ConfManager& parent,
+ const std::string& address, uint16_t port);
/** @brief Constructor to put object onto bus at a dbus path.
* @param[in] bus - Bus to attach to.
* @param[in] objPath - Path to attach at.
* @param[in] parent - Parent D-bus Object.
*/
- Client(sdbusplus::bus::bus &bus, const char *objPath, ConfManager &parent) :
+ Client(sdbusplus::bus::bus& bus, const char* objPath, ConfManager& parent) :
Ifaces(bus, objPath, true),
id(std::stol(std::experimental::filesystem::path(objPath).filename())),
parent(parent)
- {
- }
+ {}
/** @brief Update the address of the object.
*
@@ -89,7 +87,7 @@
/** Client ID. */
Id id;
/** @brief Parent D-Bus Object. */
- ConfManager &parent;
+ ConfManager& parent;
};
} // namespace snmp
diff --git a/snmp_conf_manager.cpp b/snmp_conf_manager.cpp
index 52f4678..8e42507 100644
--- a/snmp_conf_manager.cpp
+++ b/snmp_conf_manager.cpp
@@ -1,16 +1,18 @@
#include "config.h"
+
#include "snmp_conf_manager.hpp"
+
#include "snmp_serialize.hpp"
#include "snmp_util.hpp"
#include "xyz/openbmc_project/Common/error.hpp"
+#include <arpa/inet.h>
+
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include <experimental/filesystem>
-#include <arpa/inet.h>
-
namespace phosphor
{
namespace network
@@ -26,8 +28,7 @@
details::CreateIface(bus, objPath, true),
dbusPersistentLocation(SNMP_CONF_PERSIST_PATH), bus(bus),
objectPath(objPath)
-{
-}
+{}
std::string ConfManager::client(std::string address, uint16_t port)
{
diff --git a/snmp_conf_manager.hpp b/snmp_conf_manager.hpp
index de9e486..faa9954 100644
--- a/snmp_conf_manager.hpp
+++ b/snmp_conf_manager.hpp
@@ -2,8 +2,8 @@
#include "snmp_client.hpp"
-#include <xyz/openbmc_project/Network/Client/Create/server.hpp>
#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/Network/Client/Create/server.hpp>
#include <experimental/filesystem>
#include <string>
diff --git a/snmp_main.cpp b/snmp_main.cpp
index 123c05e..4522a2a 100644
--- a/snmp_main.cpp
+++ b/snmp_main.cpp
@@ -1,4 +1,5 @@
#include "config.h"
+
#include "snmp_conf_manager.hpp"
#include <phosphor-logging/log.hpp>
@@ -10,7 +11,7 @@
/* Need a custom deleter for freeing up sd_event */
struct EventDeleter
{
- void operator()(sd_event *event) const
+ void operator()(sd_event* event) const
{
event = sd_event_unref(event);
}
@@ -18,13 +19,13 @@
using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
using namespace phosphor::logging;
auto bus = sdbusplus::bus::new_default();
- sd_event *event = nullptr;
+ sd_event* event = nullptr;
auto r = sd_event_default(&event);
if (r < 0)
{
diff --git a/snmp_notification.cpp b/snmp_notification.cpp
index afce3ce..420cc01 100644
--- a/snmp_notification.cpp
+++ b/snmp_notification.cpp
@@ -1,11 +1,11 @@
#include "snmp_notification.hpp"
+
#include "snmp_util.hpp"
+#include "xyz/openbmc_project/Common/error.hpp"
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
-#include "xyz/openbmc_project/Common/error.hpp"
-
namespace phosphor
{
namespace network
diff --git a/snmp_notification.hpp b/snmp_notification.hpp
index 5102fc6..0905828 100644
--- a/snmp_notification.hpp
+++ b/snmp_notification.hpp
@@ -23,9 +23,13 @@
#pragma once
+// net-snmp requires a very specific header include order.
+// disable clang-format around this block
+// clang-format off
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
+// clang-format on
#include <sdbusplus/server.hpp>
@@ -59,24 +63,29 @@
* @tparam T - type of object from ASN type would be decided.
* @returns the ASN object type.
*/
-template <typename T> u_char getASNType() = delete;
+template <typename T>
+u_char getASNType() = delete;
-template <> u_char getASNType<uint32_t>()
+template <>
+u_char getASNType<uint32_t>()
{
return ASN_UNSIGNED;
}
-template <> u_char getASNType<uint64_t>()
+template <>
+u_char getASNType<uint64_t>()
{
return ASN_OPAQUE_U64;
}
-template <> u_char getASNType<int32_t>()
+template <>
+u_char getASNType<int32_t>()
{
return ASN_INTEGER;
}
-template <> u_char getASNType<std::string>()
+template <>
+u_char getASNType<std::string>()
{
return ASN_OCTET_STR;
}
@@ -94,10 +103,10 @@
public:
Notification() = default;
- Notification(const Notification &) = delete;
- Notification(Notification &&) = default;
- Notification &operator=(const Notification &) = delete;
- Notification &operator=(Notification &&) = default;
+ Notification(const Notification&) = delete;
+ Notification(Notification&&) = default;
+ Notification& operator=(const Notification&) = delete;
+ Notification& operator=(Notification&&) = default;
virtual ~Notification() = default;
/** @brief Send the snmp trap to the configured
@@ -114,7 +123,7 @@
* @param[in] val - Value of the object.
* @returns true on success otherwise false.
*/
- bool addPDUVar(netsnmp_pdu &pdu, const OID &objID, size_t objIDLen,
+ bool addPDUVar(netsnmp_pdu& pdu, const OID& objID, size_t objIDLen,
u_char type, Value val);
/** @brief get the SNMP notification type in the mib
@@ -150,10 +159,10 @@
public:
OBMCErrorNotification() = default;
- OBMCErrorNotification(const OBMCErrorNotification &) = delete;
- OBMCErrorNotification(OBMCErrorNotification &&) = default;
- OBMCErrorNotification &operator=(const OBMCErrorNotification &) = delete;
- OBMCErrorNotification &operator=(OBMCErrorNotification &&) = default;
+ OBMCErrorNotification(const OBMCErrorNotification&) = delete;
+ OBMCErrorNotification(OBMCErrorNotification&&) = default;
+ OBMCErrorNotification& operator=(const OBMCErrorNotification&) = delete;
+ OBMCErrorNotification& operator=(OBMCErrorNotification&&) = default;
~OBMCErrorNotification() = default;
/** @brief Constructor
@@ -166,8 +175,7 @@
std::string msg) :
OBMCErrorID(id),
OBMCErrorTimestamp(ts), OBMCErrorSeverity(sev), OBMCErrorMessage(msg)
- {
- }
+ {}
protected:
std::pair<OID, OID_LEN> getTrapOID() override
diff --git a/snmp_serialize.cpp b/snmp_serialize.cpp
index 98aa97f..2a04109 100644
--- a/snmp_serialize.cpp
+++ b/snmp_serialize.cpp
@@ -1,12 +1,15 @@
-#include <cereal/types/string.hpp>
-#include <cereal/types/vector.hpp>
-#include <cereal/archives/binary.hpp>
-#include <fstream>
+#include "config.h"
#include "snmp_serialize.hpp"
+
#include "snmp_client.hpp"
+
+#include <cereal/archives/binary.hpp>
+#include <cereal/types/string.hpp>
+#include <cereal/types/vector.hpp>
#include <phosphor-logging/log.hpp>
-#include "config.h"
+
+#include <fstream>
// Register class version
// From cereal documentation;
diff --git a/snmp_serialize.hpp b/snmp_serialize.hpp
index 2608866..8f1400e 100644
--- a/snmp_serialize.hpp
+++ b/snmp_serialize.hpp
@@ -1,8 +1,9 @@
#pragma once
-#include <experimental/filesystem>
#include "snmp_client.hpp"
+#include <experimental/filesystem>
+
namespace phosphor
{
namespace network
diff --git a/snmp_util.cpp b/snmp_util.cpp
index e12133b..e09a32b 100644
--- a/snmp_util.cpp
+++ b/snmp_util.cpp
@@ -1,13 +1,13 @@
#include "snmp_util.hpp"
+
#include "xyz/openbmc_project/Common/error.hpp"
#include <arpa/inet.h>
+#include <netdb.h>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
-#include <netdb.h>
-#include <arpa/inet.h>
#include <string>
namespace phosphor
diff --git a/snmp_util.hpp b/snmp_util.hpp
index aef8c46..2ee7dac 100644
--- a/snmp_util.hpp
+++ b/snmp_util.hpp
@@ -1,15 +1,15 @@
#pragma once
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/socket.h>
#include <netdb.h>
+#include <stdint.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+
+#include <sdbusplus/server.hpp>
#include <map>
#include <string>
-#include <sdbusplus/server.hpp>
-
namespace phosphor
{
diff --git a/test/test_error_notification.cpp b/test/test_error_notification.cpp
index 580a820..71a554a 100644
--- a/test/test_error_notification.cpp
+++ b/test/test_error_notification.cpp
@@ -1,7 +1,9 @@
#include "snmp_notification.hpp"
-#include <gtest/gtest.h>
+
#include <netinet/in.h>
+#include <gtest/gtest.h>
+
namespace phosphor
{
namespace network
diff --git a/test/test_snmp_client.cpp b/test/test_snmp_client.cpp
index 04fbdf8..1dd9eb4 100644
--- a/test/test_snmp_client.cpp
+++ b/test/test_snmp_client.cpp
@@ -1,9 +1,9 @@
-#include <gtest/gtest.h>
+#include "snmp_conf_manager.hpp"
+#include "snmp_serialize.hpp"
#include <xyz/openbmc_project/Common/error.hpp>
-#include "snmp_conf_manager.hpp"
-#include "snmp_serialize.hpp"
+#include <gtest/gtest.h>
namespace phosphor
{
diff --git a/test/test_snmp_conf_manager.cpp b/test/test_snmp_conf_manager.cpp
index 6cb2a53..bcf89e7 100644
--- a/test/test_snmp_conf_manager.cpp
+++ b/test/test_snmp_conf_manager.cpp
@@ -1,10 +1,10 @@
#include "snmp_conf_manager.hpp"
-
#include "xyz/openbmc_project/Common/error.hpp"
-#include <gtest/gtest.h>
#include <sdbusplus/bus.hpp>
+#include <gtest/gtest.h>
+
namespace phosphor
{
namespace network
@@ -40,14 +40,14 @@
return manager.client(ipaddress, port);
}
- ClientList &getSNMPClients()
+ ClientList& getSNMPClients()
{
return manager.clients;
}
- bool isClientExist(const std::string &ipaddress)
+ bool isClientExist(const std::string& ipaddress)
{
- for (const auto &val : manager.clients)
+ for (const auto& val : manager.clients)
{
if (val.second.get()->address() == ipaddress)
{
@@ -59,7 +59,7 @@
void deleteSNMPClient(std::string ipaddress)
{
- for (const auto &val : manager.clients)
+ for (const auto& val : manager.clients)
{
if (val.second.get()->address() == ipaddress)
{
@@ -80,7 +80,7 @@
EXPECT_EQ(path, expectedPath);
// check whether the client created
- auto &clients = getSNMPClients();
+ auto& clients = getSNMPClients();
EXPECT_EQ(1, clients.size());
EXPECT_EQ(true, isClientExist("192.168.1.1"));
}
@@ -98,7 +98,7 @@
EXPECT_EQ(path, expectedPath);
// check both the clients get created
- auto &clients = getSNMPClients();
+ auto& clients = getSNMPClients();
EXPECT_EQ(2, clients.size());
EXPECT_EQ(true, isClientExist("192.168.1.1"));
@@ -118,7 +118,7 @@
createSNMPClient("192.168.1.1", 24);
createSNMPClient("192.168.1.2", 24);
- auto &clients = getSNMPClients();
+ auto& clients = getSNMPClients();
EXPECT_EQ(2, clients.size());
deleteSNMPClient("192.168.1.1");
diff --git a/test/test_snmp_serialize.cpp b/test/test_snmp_serialize.cpp
index c276cb1..1b0928e 100644
--- a/test/test_snmp_serialize.cpp
+++ b/test/test_snmp_serialize.cpp
@@ -1,12 +1,14 @@
-#include <experimental/filesystem>
-#include <fstream>
-#include <gtest/gtest.h>
-#include <netinet/in.h>
-
#include "snmp_client.hpp"
#include "snmp_conf_manager.hpp"
#include "snmp_serialize.hpp"
+#include <netinet/in.h>
+
+#include <experimental/filesystem>
+#include <fstream>
+
+#include <gtest/gtest.h>
+
namespace phosphor
{
namespace network
diff --git a/test/test_snmp_util.cpp b/test/test_snmp_util.cpp
index 7bc5b43..5dca0ef 100644
--- a/test/test_snmp_util.cpp
+++ b/test/test_snmp_util.cpp
@@ -1,8 +1,11 @@
-#include <gtest/gtest.h>
-#include <netinet/in.h>
#include "snmp_util.hpp"
+
+#include <netinet/in.h>
+
#include <xyz/openbmc_project/Common/error.hpp>
+#include <gtest/gtest.h>
+
namespace phosphor
{
namespace network