Update to latest clang-format
Refer:https://github.com/openbmc/docs/blob/ac5d544553934f8083c61c5986a1420261bc8a4c/style/cpp/.clang-format
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I1e06864afc29ce7de463e62fa2a0eb6f70e8fd93
diff --git a/.clang-format b/.clang-format
index 692faa2..79a474d 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,10 +14,9 @@
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: true
+AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
@@ -30,19 +29,27 @@
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: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
+DeriveLineEnding: false
DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
@@ -52,21 +59,25 @@
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
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -84,8 +95,13 @@
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,8 +109,8 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
+UseCRLF: false
UseTab: Never
...
-
diff --git a/auth_algo.hpp b/auth_algo.hpp
index 894a853..f940370 100644
--- a/auth_algo.hpp
+++ b/auth_algo.hpp
@@ -54,8 +54,7 @@
crypt::Algorithms cryptAlgo) :
intAlgo(intAlgo),
cryptAlgo(cryptAlgo)
- {
- }
+ {}
Interface() = delete;
virtual ~Interface() = default;
@@ -167,8 +166,7 @@
explicit AlgoSHA1(integrity::Algorithms intAlgo,
crypt::Algorithms cryptAlgo) :
Interface(intAlgo, cryptAlgo)
- {
- }
+ {}
AlgoSHA1() = delete;
~AlgoSHA1() = default;
@@ -203,8 +201,7 @@
explicit AlgoSHA256(integrity::Algorithms intAlgo,
crypt::Algorithms cryptAlgo) :
Interface(intAlgo, cryptAlgo)
- {
- }
+ {}
~AlgoSHA256() = default;
AlgoSHA256(const AlgoSHA256&) = default;
diff --git a/command/channel_auth.cpp b/command/channel_auth.cpp
index fd1fa5b..e83ad95 100644
--- a/command/channel_auth.cpp
+++ b/command/channel_auth.cpp
@@ -2,18 +2,19 @@
#include <ipmid/api.h>
-#include <fstream>
#include <ipmid/types.hpp>
#include <ipmid/utils.hpp>
#include <nlohmann/json.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
-#include <set>
-#include <string>
#include <user_channel/channel_layer.hpp>
#include <user_channel/user_layer.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <fstream>
+#include <set>
+#include <string>
+
namespace command
{
diff --git a/command/guid.cpp b/command/guid.cpp
index c69f825..26e73e8 100644
--- a/command/guid.cpp
+++ b/command/guid.cpp
@@ -4,6 +4,7 @@
#include <mapper.h>
#include <phosphor-logging/log.hpp>
+
#include <sstream>
#include <string>
diff --git a/command/guid.hpp b/command/guid.hpp
index f73e449..04f289a 100644
--- a/command/guid.hpp
+++ b/command/guid.hpp
@@ -2,8 +2,9 @@
#include "comm_module.hpp"
-#include <cstddef>
#include <sdbusplus/bus/match.hpp>
+
+#include <cstddef>
#include <vector>
namespace command
diff --git a/command/rakp12.cpp b/command/rakp12.cpp
index b8dc17c..bec5c4f 100644
--- a/command/rakp12.cpp
+++ b/command/rakp12.cpp
@@ -7,11 +7,12 @@
#include <openssl/rand.h>
+#include <ipmid/types.hpp>
+#include <phosphor-logging/log.hpp>
+
#include <algorithm>
#include <cstring>
#include <iomanip>
-#include <ipmid/types.hpp>
-#include <phosphor-logging/log.hpp>
using namespace phosphor::logging;
diff --git a/command/rakp34.cpp b/command/rakp34.cpp
index cfa2363..bee475d 100644
--- a/command/rakp34.cpp
+++ b/command/rakp34.cpp
@@ -6,9 +6,10 @@
#include "rmcp.hpp"
#include "sessions_manager.hpp"
+#include <phosphor-logging/log.hpp>
+
#include <algorithm>
#include <cstring>
-#include <phosphor-logging/log.hpp>
using namespace phosphor::logging;
@@ -67,7 +68,6 @@
std::vector<uint8_t> RAKP34(const std::vector<uint8_t>& inPayload,
std::shared_ptr<message::Handler>& handler)
{
-
std::vector<uint8_t> outPayload(sizeof(RAKP4response));
auto request = reinterpret_cast<const RAKP3request*>(inPayload.data());
auto response = reinterpret_cast<RAKP4response*>(outPayload.data());
diff --git a/command/session_cmds.cpp b/command/session_cmds.cpp
index da34c3c..25e906e 100644
--- a/command/session_cmds.cpp
+++ b/command/session_cmds.cpp
@@ -5,11 +5,12 @@
#include <ipmid/api.h>
-#include <chrono>
#include <ipmid/sessionhelper.hpp>
#include <ipmid/utils.hpp>
#include <phosphor-logging/log.hpp>
+#include <chrono>
+
using namespace std::chrono_literals;
namespace command
diff --git a/command/session_cmds.hpp b/command/session_cmds.hpp
index 026b9d8..05c312e 100644
--- a/command/session_cmds.hpp
+++ b/command/session_cmds.hpp
@@ -21,7 +21,6 @@
*/
struct SetSessionPrivLevelReq
{
-
#if BYTE_ORDER == LITTLE_ENDIAN
uint8_t reqPrivLevel : 4;
uint8_t reserved : 4;
diff --git a/command_table.cpp b/command_table.cpp
index 1514274..00acc65 100644
--- a/command_table.cpp
+++ b/command_table.cpp
@@ -5,7 +5,6 @@
#include "message_parsers.hpp"
#include "sessions_manager.hpp"
-#include <iomanip>
#include <ipmid/types.hpp>
#include <main.hpp>
#include <phosphor-logging/elog-errors.hpp>
@@ -13,6 +12,8 @@
#include <user_channel/user_layer.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <iomanip>
+
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
using namespace phosphor::logging;
diff --git a/command_table.hpp b/command_table.hpp
index d65db12..295c659 100644
--- a/command_table.hpp
+++ b/command_table.hpp
@@ -15,8 +15,7 @@
{
static constexpr size_t lunBits = 2;
CommandID(uint32_t command) : command(command)
- {
- }
+ {}
uint8_t netFnLun() const
{
@@ -115,12 +114,10 @@
class Entry
{
-
public:
Entry(CommandID command, session::Privilege privilege) :
command(command), privilege(privilege)
- {
- }
+ {}
/**
* @brief Execute the command
@@ -172,14 +169,12 @@
*/
class NetIpmidEntry final : public Entry
{
-
public:
NetIpmidEntry(CommandID command, CommandFunctor functor,
session::Privilege privilege, bool sessionless) :
Entry(command, privilege),
functor(functor), sessionless(sessionless)
- {
- }
+ {}
/**
* @brief Execute the command
@@ -218,13 +213,11 @@
{
private:
struct Private
- {
- };
+ {};
public:
explicit Table(const Private&)
- {
- }
+ {}
Table() = delete;
~Table() = default;
// Command Table is a singleton so copy, copy-assignment, move and
diff --git a/crypt_algo.hpp b/crypt_algo.hpp
index f4d7363..1064772 100644
--- a/crypt_algo.hpp
+++ b/crypt_algo.hpp
@@ -44,8 +44,7 @@
* @brief Constructor for Interface
*/
explicit Interface(const std::vector<uint8_t>& k2) : k2(k2)
- {
- }
+ {}
Interface() = delete;
virtual ~Interface() = default;
@@ -145,8 +144,7 @@
* @param[in] - Session Integrity key
*/
explicit AlgoAES128(const std::vector<uint8_t>& k2) : Interface(k2)
- {
- }
+ {}
AlgoAES128() = delete;
~AlgoAES128() = default;
diff --git a/integrity_algo.cpp b/integrity_algo.cpp
index bac87d7..43035dc 100644
--- a/integrity_algo.cpp
+++ b/integrity_algo.cpp
@@ -43,7 +43,6 @@
const std::vector<uint8_t>& packet, const size_t length,
std::vector<uint8_t>::const_iterator integrityData) const
{
-
auto output = generateHMAC(
packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE, length);
@@ -108,7 +107,6 @@
const std::vector<uint8_t>& packet, const size_t length,
std::vector<uint8_t>::const_iterator integrityData) const
{
-
auto output = generateHMAC(
packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE, length);
diff --git a/integrity_algo.hpp b/integrity_algo.hpp
index cdeb617..3640ce2 100644
--- a/integrity_algo.hpp
+++ b/integrity_algo.hpp
@@ -48,8 +48,7 @@
* @param[in] - AuthCode length
*/
explicit Interface(size_t authLength) : authCodeLength(authLength)
- {
- }
+ {}
Interface() = delete;
virtual ~Interface() = default;
diff --git a/main.cpp b/main.cpp
index 17fecfa..fc9a28c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -21,9 +21,10 @@
#include <CLI/CLI.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/asio/connection.hpp>
-#include <tuple>
#include <user_channel/channel_layer.hpp>
+#include <tuple>
+
using namespace phosphor::logging;
static auto io = std::make_shared<boost::asio::io_context>();
diff --git a/main.hpp b/main.hpp
index fa7584b..a5be04c 100644
--- a/main.hpp
+++ b/main.hpp
@@ -1,9 +1,10 @@
#pragma once
#include <boost/asio/io_context.hpp>
+#include <sdbusplus/asio/connection.hpp>
+
#include <cstddef>
#include <memory>
-#include <sdbusplus/asio/connection.hpp>
// Select call timeout is set arbitrarily set to 30 sec
static constexpr size_t SELECT_CALL_TIMEOUT = 30;
diff --git a/message.hpp b/message.hpp
index 721a7b1..b486c77 100644
--- a/message.hpp
+++ b/message.hpp
@@ -123,8 +123,7 @@
rcSessionID(Message::MESSAGE_INVALID_SESSION_ID),
bmcSessionID(Message::MESSAGE_INVALID_SESSION_ID),
rmcpMsgClass(ClassOfMsg::RESERVED)
- {
- }
+ {}
/**
* @brief Special behavior for copy constructor
diff --git a/message_handler.cpp b/message_handler.cpp
index 33bb195..861d69f 100644
--- a/message_handler.cpp
+++ b/message_handler.cpp
@@ -8,8 +8,9 @@
#include <sys/socket.h>
-#include <memory>
#include <phosphor-logging/log.hpp>
+
+#include <memory>
#include <string>
#include <vector>
@@ -108,7 +109,6 @@
void Handler::executeCommand()
{
-
// Get the CommandID to map into the command table
auto command = inMessage->getCommand();
if (inMessage->payloadType == PayloadType::IPMI)
diff --git a/message_handler.hpp b/message_handler.hpp
index 2eb4737..88197ca 100644
--- a/message_handler.hpp
+++ b/message_handler.hpp
@@ -22,8 +22,7 @@
uint32_t sessionID = message::Message::MESSAGE_INVALID_SESSION_ID) :
sessionID(sessionID),
channel(channel), io(io)
- {
- }
+ {}
/**
* @brief Create a Handler intended for a send only (SOL)
@@ -32,8 +31,7 @@
uint32_t sessionID = message::Message::MESSAGE_INVALID_SESSION_ID) :
sessionID(sessionID),
channel(channel), io(nullptr)
- {
- }
+ {}
~Handler();
Handler() = delete;
diff --git a/sd_event_loop.hpp b/sd_event_loop.hpp
index 1c3d1c2..f580b32 100644
--- a/sd_event_loop.hpp
+++ b/sd_event_loop.hpp
@@ -6,9 +6,10 @@
#include <systemd/sd-event.h>
#include <boost/asio/io_context.hpp>
+#include <sdbusplus/asio/connection.hpp>
+
#include <chrono>
#include <map>
-#include <sdbusplus/asio/connection.hpp>
#include <string>
namespace ipmi
@@ -43,14 +44,12 @@
{
private:
struct Private
- {
- };
+ {};
public:
EventLoop(std::shared_ptr<boost::asio::io_context>& io, const Private&) :
io(io)
- {
- }
+ {}
EventLoop() = delete;
~EventLoop() = default;
EventLoop(const EventLoop&) = delete;
diff --git a/session.hpp b/session.hpp
index a01d478..69dbc3c 100644
--- a/session.hpp
+++ b/session.hpp
@@ -7,21 +7,22 @@
#include "prng.hpp"
#include "socket_channel.hpp"
-#include <chrono>
-#include <exception>
#include <ipmid/api.hpp>
#include <ipmid/sessiondef.hpp>
-#include <list>
-#include <memory>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
-#include <string>
-#include <unordered_map>
#include <user_channel/channel_layer.hpp>
#include <user_channel/user_layer.hpp>
-#include <vector>
#include <xyz/openbmc_project/Ipmi/SessionInfo/server.hpp>
+#include <chrono>
+#include <exception>
+#include <list>
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
namespace session
{
diff --git a/sessions_manager.cpp b/sessions_manager.cpp
index ace75c3..b01ba4a 100644
--- a/sessions_manager.cpp
+++ b/sessions_manager.cpp
@@ -3,13 +3,14 @@
#include "main.hpp"
#include "session.hpp"
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/asio/connection.hpp>
+#include <user_channel/channel_layer.hpp>
+
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <memory>
-#include <phosphor-logging/log.hpp>
-#include <sdbusplus/asio/connection.hpp>
-#include <user_channel/channel_layer.hpp>
using namespace phosphor::logging;
@@ -21,7 +22,6 @@
void Manager::setNetworkInstance(void)
{
-
uint8_t index = 0, ch = 1;
// Constructing net-ipmid instances list based on channel info
// valid channel start from 1 to 15 and assuming max 4 LAN channel
@@ -35,7 +35,6 @@
if (static_cast<ipmi::EChannelMediumType>(chInfo.mediumType) ==
ipmi::EChannelMediumType::lan8032)
{
-
if (getInterfaceIndex() == ch)
{
ipmiNetworkInstance = index;
@@ -55,7 +54,6 @@
void Manager::managerInit(const std::string& channel)
{
-
/*
* Session ID is 0000_0000h for messages that are sent outside the session.
* The session setup commands are sent on this session, so when the session
@@ -315,7 +313,6 @@
uint8_t Manager::getSessionHandle(SessionID bmcSessionID) const
{
-
// Handler index 0 is reserved for invalid session.
// index starts with 1, for direct usage. Index 0 reserved
for (size_t i = 1; i < session::maxSessionHandles; i++)
@@ -329,7 +326,6 @@
}
uint8_t Manager::getActiveSessionCount() const
{
-
return (std::count_if(
sessionsMap.begin(), sessionsMap.end(),
[](const std::pair<const uint32_t, std::shared_ptr<Session>>& in)
@@ -344,9 +340,8 @@
std::chrono::duration expTime = timer.expires_from_now();
if (expTime > std::chrono::microseconds(0) && expTime < when)
{
- // if timer has not already expired AND
- // requested timeout is greater than current timeout
- // then ignore this new requested timeout
+ // if timer has not already expired AND requested timeout is greater
+ // than current timeout then ignore this new requested timeout
return;
}
timer.expires_from_now(when);
diff --git a/sessions_manager.hpp b/sessions_manager.hpp
index 5fefbcc..cd7f016 100644
--- a/sessions_manager.hpp
+++ b/sessions_manager.hpp
@@ -4,9 +4,10 @@
#include "session.hpp"
#include <boost/asio/steady_timer.hpp>
-#include <chrono>
#include <ipmid/api.hpp>
#include <ipmid/sessiondef.hpp>
+
+#include <chrono>
#include <map>
#include <memory>
#include <mutex>
@@ -35,8 +36,7 @@
{
private:
struct Private
- {
- };
+ {};
public:
// BMC Session ID is the key for the map
diff --git a/socket_channel.hpp b/socket_channel.hpp
index b993f0e..7179e2c 100644
--- a/socket_channel.hpp
+++ b/socket_channel.hpp
@@ -4,9 +4,10 @@
#include <sys/types.h>
#include <boost/asio/ip/udp.hpp>
+#include <phosphor-logging/log.hpp>
+
#include <memory>
#include <optional>
-#include <phosphor-logging/log.hpp>
#include <string>
#include <tuple>
#include <variant>
@@ -42,8 +43,7 @@
*/
explicit Channel(std::shared_ptr<boost::asio::ip::udp::socket> socket) :
socket(socket)
- {
- }
+ {}
/**
* @brief Check if ip address is ipv4 mapped ipv6
*
diff --git a/sol/sol_context.hpp b/sol/sol_context.hpp
index a071892..34a0076 100644
--- a/sol/sol_context.hpp
+++ b/sol/sol_context.hpp
@@ -5,6 +5,7 @@
#include <boost/asio/io_context.hpp>
#include <boost/asio/steady_timer.hpp>
+
#include <cstddef>
namespace sol
diff --git a/sol/sol_manager.cpp b/sol/sol_manager.cpp
index 76f0bd8..870bc6a 100644
--- a/sol/sol_manager.cpp
+++ b/sol/sol_manager.cpp
@@ -10,12 +10,13 @@
#include <boost/asio/io_context.hpp>
#include <boost/asio/local/stream_protocol.hpp>
#include <boost/asio/write.hpp>
-#include <chrono>
-#include <cmath>
#include <ipmid/utils.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/message/types.hpp>
+#include <chrono>
+#include <cmath>
+
constexpr const char* solInterface = "xyz.openbmc_project.Ipmi.SOL";
constexpr const char* solPath = "/xyz/openbmc_project/ipmi/sol/";
constexpr const char* PROP_INTF = "org.freedesktop.DBus.Properties";
diff --git a/sol/sol_manager.hpp b/sol/sol_manager.hpp
index 16a47fa..72c13b4 100644
--- a/sol/sol_manager.hpp
+++ b/sol/sol_manager.hpp
@@ -7,6 +7,7 @@
#include <boost/asio/io_context.hpp>
#include <boost/asio/local/stream_protocol.hpp>
+
#include <cstddef>
#include <map>
#include <memory>
@@ -39,8 +40,7 @@
{
private:
struct Private
- {
- };
+ {};
public:
/** @brief SOL Payload Instance is the key for the map, the value is the
@@ -57,8 +57,7 @@
Manager(std::shared_ptr<boost::asio::io_context>& io, const Private&) :
io(io)
- {
- }
+ {}
/**
* @brief Get a reference to the singleton Manager