Update .clang-format and reformat
Update the local .clang-format to the example configuration and reformat
all the source code, as well as line wrap the README text.
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Change-Id: I996d96a14a271612e03113013e29f4613b782c35
diff --git a/.clang-format b/.clang-format
index dd27708..5f0cb09 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,22 +5,22 @@
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
-AlignOperands: true
+AlignEscapedNewlines: Right
+AlignOperands: Align
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
+AllowShortFunctionsOnASingleLine: Empty
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,20 +29,28 @@
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
-DerivePointerAlignment: true
+DeriveLineEnding: false
+DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
@@ -51,21 +59,26 @@
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
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -73,18 +86,28 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Right
+PenaltyIndentedWhitespace: 0
+QualifierAlignment: Left
+ReferenceAlignment: Left
ReflowComments: true
+RequiresClausePosition: OwnLine
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
@@ -92,7 +115,9 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
+UseCRLF: false
UseTab: Never
...
+
diff --git a/README.md b/README.md
index b0c75d9..8b2038b 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
# phosphor-post-code-manager
-This phosphor-post-code-manager repository provides an infrastructure to persist the POST codes in BMC filesystem & it also owns
-the systemd services that are responsible for exposing the BIOS Post Codes to rest of the world via redfish.
+This phosphor-post-code-manager repository provides an infrastructure to persist
+the POST codes in BMC filesystem & it also owns the systemd services that are
+responsible for exposing the BIOS Post Codes to rest of the world via redfish.
## To Build
@@ -14,12 +15,23 @@
## Hosted Services
-This repository ships `xyz.openbmc_project.State.Boot.PostCode.service` systemd service along with its [template version](https://github.com/openbmc/docs/blob/master/designs/multi-host-postcode.md) and a tiny binary that exposes the necessary [dbus interfaces & methods](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/Boot/PostCode.interface.yaml) to extract the POST codes per boot cycle.
+This repository ships `xyz.openbmc_project.State.Boot.PostCode.service` systemd
+service along with its [template
+version](https://github.com/openbmc/docs/blob/master/designs/multi-host-postcode.md)
+and a tiny binary that exposes the necessary [dbus interfaces &
+methods](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/Boot/PostCode.interface.yaml)
+to extract the POST codes per boot cycle.
## Architecture
-This repository is tightly coupled with [phosphor-host-postd](https://github.com/openbmc/phosphor-host-postd) OpenBMC respository which is responsible for emitting the dbus signals for every new POST Code.
+This repository is tightly coupled with
+[phosphor-host-postd](https://github.com/openbmc/phosphor-host-postd) OpenBMC
+respository which is responsible for emitting the dbus signals for every new
+POST Code.
-phosphor-post-code-manager is architected to look for the property changed signals which are being emitted from the service that hosts [Value](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/Boot/Raw.interface.yaml) property on `xyz.openbmc_project.State.Boot.Raw` interface & archive them per boot on the filesystem, so that those can be exposed over [redfish](https://github.com/openbmc/docs/blob/master/designs/redfish-postcodes.md)
-
-
+phosphor-post-code-manager is architected to look for the property changed
+signals which are being emitted from the service that hosts
+[Value](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/Boot/Raw.interface.yaml)
+property on `xyz.openbmc_project.State.Boot.Raw` interface & archive them per
+boot on the filesystem, so that those can be exposed over
+[redfish](https://github.com/openbmc/docs/blob/master/designs/redfish-postcodes.md)
diff --git a/inc/post_code.hpp b/inc/post_code.hpp
index 462e8cd..1e9b493 100644
--- a/inc/post_code.hpp
+++ b/inc/post_code.hpp
@@ -24,31 +24,29 @@
#include <cereal/types/map.hpp>
#include <cereal/types/tuple.hpp>
#include <cereal/types/vector.hpp>
-#include <chrono>
-#include <filesystem>
-#include <fstream>
-#include <iostream>
#include <phosphor-logging/elog-errors.hpp>
#include <xyz/openbmc_project/Collection/DeleteAll/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/State/Boot/PostCode/server.hpp>
#include <xyz/openbmc_project/State/Host/server.hpp>
-const static constexpr char *CurrentBootCycleCountName =
+#include <chrono>
+#include <filesystem>
+#include <fstream>
+#include <iostream>
+
+const static constexpr char* CurrentBootCycleCountName =
"CurrentBootCycleCount";
-const static constexpr char *CurrentBootCycleIndexName =
+const static constexpr char* CurrentBootCycleIndexName =
"CurrentBootCycleIndex";
// Singleton holder to store host/node and other path information
class PostCodeDataHolder
{
-
- PostCodeDataHolder()
- {
- }
+ PostCodeDataHolder() {}
public:
- static PostCodeDataHolder &getInstance()
+ static PostCodeDataHolder& getInstance()
{
static PostCodeDataHolder instance;
return instance;
@@ -56,19 +54,19 @@
int node;
- const static constexpr char *PostCodePath =
+ const static constexpr char* PostCodePath =
"/xyz/openbmc_project/state/boot/raw";
- const static constexpr char *PropertiesIntf =
+ const static constexpr char* PropertiesIntf =
"org.freedesktop.DBus.Properties";
- const static constexpr char *PostCodeListPathPrefix =
+ const static constexpr char* PostCodeListPathPrefix =
"/var/lib/phosphor-post-code-manager/host";
- const static constexpr char *HostStatePathPrefix =
+ const static constexpr char* HostStatePathPrefix =
"/xyz/openbmc_project/state/host";
};
struct EventDeleter
{
- void operator()(sd_event *event) const
+ void operator()(sd_event* event) const
{
sd_event_unref(event);
}
@@ -90,7 +88,7 @@
PostCodeDataHolder postcodeDataHolderObj =
PostCodeDataHolder::getInstance();
- PostCode(sdbusplus::bus_t &bus, const char *path, EventPtr & /*event*/) :
+ PostCode(sdbusplus::bus_t& bus, const char* path, EventPtr& /*event*/) :
sdbusplus::server::object_t<post_code, delete_all>(bus, path), bus(bus),
propertiesChangedSignalRaw(
bus,
@@ -101,7 +99,7 @@
std::to_string(postcodeDataHolderObj.node)) +
sdbusplus::bus::match::rules::interface(
postcodeDataHolderObj.PropertiesIntf),
- [this](sdbusplus::message_t &msg) {
+ [this](sdbusplus::message_t& msg) {
std::string objectName;
std::map<std::string, std::variant<postcode_t>> msgData;
msg.read(objectName, msgData);
@@ -124,7 +122,7 @@
std::to_string(postcodeDataHolderObj.node)) +
sdbusplus::bus::match::rules::interface(
postcodeDataHolderObj.PropertiesIntf),
- [this](sdbusplus::message_t &msg) {
+ [this](sdbusplus::message_t& msg) {
std::string objectName;
std::map<std::string, std::variant<std::string>> msgData;
msg.read(objectName, msgData);
@@ -176,9 +174,7 @@
currentBootCycleCount(count);
maxBootCycleNum(MAX_BOOT_CYCLE_COUNT);
}
- ~PostCode()
- {
- }
+ ~PostCode() {}
std::vector<postcode_t> getPostCodes(uint16_t index) override;
std::map<uint64_t, postcode_t>
@@ -189,7 +185,7 @@
void incrBootCycle();
uint16_t getBootNum(const uint16_t index) const;
- sdbusplus::bus_t &bus;
+ sdbusplus::bus_t& bus;
std::chrono::time_point<std::chrono::steady_clock> firstPostCodeTimeSteady;
uint64_t firstPostCodeUsSinceEpoch;
std::map<uint64_t, postcode_t> postCodes;
@@ -200,8 +196,8 @@
void savePostCodes(postcode_t code);
sdbusplus::bus::match_t propertiesChangedSignalRaw;
sdbusplus::bus::match_t propertiesChangedSignalCurrentHostState;
- fs::path serialize(const std::string &path);
- bool deserialize(const fs::path &path, uint16_t &index);
- bool deserializePostCodes(const fs::path &path,
- std::map<uint64_t, postcode_t> &codes);
+ fs::path serialize(const std::string& path);
+ bool deserialize(const fs::path& path, uint16_t& index);
+ bool deserializePostCodes(const fs::path& path,
+ std::map<uint64_t, postcode_t>& codes);
};