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: Id3ff2ed97fd733b2bbfe6e4890c2e6dd8c212085
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index 38b2669..d92a3f1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -6,12 +6,14 @@
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
-AlignOperands: true
-AlignTrailingComments: true
+AlignOperands: Align
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
+AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
@@ -36,12 +38,13 @@
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
+BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
-BreakStringLiterals: true
+BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
@@ -49,6 +52,7 @@
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
+DeriveLineEnding: false
DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
@@ -74,9 +78,13 @@
- Regex: '.*'
Priority: 6
IndentCaseLabels: true
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -84,14 +92,20 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 0
+QualifierAlignment: Left
+ReferenceAlignment: Left
ReflowComments: true
-SortIncludes: false
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
+SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
@@ -108,7 +122,7 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
diff --git a/include/biccommands.hpp b/include/biccommands.hpp
index 44d0e76..dfce3a4 100644
--- a/include/biccommands.hpp
+++ b/include/biccommands.hpp
@@ -1,3 +1,4 @@
+#include <cstdint>
enum class fb_bic_cmds : uint8_t
{
diff --git a/include/commandutils.hpp b/include/commandutils.hpp
index b9290d0..5658c1c 100644
--- a/include/commandutils.hpp
+++ b/include/commandutils.hpp
@@ -15,10 +15,12 @@
*/
#pragma once
+#include "config.h"
+
+#include <ipmid/api.hpp>
#include <sdbusplus/bus.hpp>
#include <iostream>
-#include "config.h"
static constexpr bool debug = false;
diff --git a/include/sensorutils.hpp b/include/sensorutils.hpp
index 5e88dc4..00e844d 100644
--- a/include/sensorutils.hpp
+++ b/include/sensorutils.hpp
@@ -77,10 +77,10 @@
return false;
}
sdbusplus::bus_t dbus(bus);
- auto mapperCall =
- dbus.new_method_call("xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree");
+ auto mapperCall = dbus.new_method_call("xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper",
+ "GetSubTree");
static constexpr const auto depth = 2;
static constexpr std::array<const char*, 3> interfaces = {
"xyz.openbmc_project.Sensor.Value",
diff --git a/include/usb-dbg.hpp b/include/usb-dbg.hpp
index dce82e5..0f6a0c7 100644
--- a/include/usb-dbg.hpp
+++ b/include/usb-dbg.hpp
@@ -21,12 +21,12 @@
#include <appcommands.hpp>
#include <ipmid/api.hpp>
+#include <ipmid/utils.hpp>
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
#include <phosphor-logging/lg2.hpp>
+#include <phosphor-logging/log.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/property.hpp>
-#include <ipmid/utils.hpp>
#include <fstream>
#include <iomanip>
@@ -99,8 +99,7 @@
uint8_t esc_sts;
uint8_t overwrite;
time_t mtime;
- frame() : buf(NULL), pages(0), mtime(0)
- {}
+ frame() : buf(NULL), pages(0), mtime(0) {}
int init(size_t size);
int append(const char* string, int indent);
int insert(const char* string, int indent);
diff --git a/meson_config.h.in b/meson_config.h.in
index 6b8af72..d4470a0 100644
--- a/meson_config.h.in
+++ b/meson_config.h.in
@@ -1,4 +1,5 @@
#pragma once
+#include <string>
inline static const std::string hostInstances = @INSTANCES@;
diff --git a/src/appcommands.cpp b/src/appcommands.cpp
index e0ae4ed..ed9e365 100644
--- a/src/appcommands.cpp
+++ b/src/appcommands.cpp
@@ -22,11 +22,11 @@
#include <appcommands.hpp>
#include <commandutils.hpp>
+#include <ipmid/api-types.hpp>
+#include <ipmid/api.hpp>
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/message/types.hpp>
-#include <ipmid/api.hpp>
-#include <ipmid/api-types.hpp>
#include <fstream>
#include <iomanip>
@@ -313,7 +313,6 @@
ipmi::RspType<uint8_t> ipmiAppSetSysInfoParams(ipmi::Context::ptr ctx,
std::vector<uint8_t> req)
{
-
uint8_t param = req[0];
uint8_t req_len = req.size();
std::optional<size_t> hostId = findHost(ctx->hostIdx);
diff --git a/src/biccommands.cpp b/src/biccommands.cpp
index e0bb322..49ae97f 100644
--- a/src/biccommands.cpp
+++ b/src/biccommands.cpp
@@ -15,16 +15,15 @@
* limitations under the License.
*/
-#include <ipmid/api.hpp>
-#include <ipmid/api-types.hpp>
-
-#include <commandutils.hpp>
#include <biccommands.hpp>
+#include <commandutils.hpp>
+#include <ipmid/api-types.hpp>
+#include <ipmid/api.hpp>
#include <phosphor-logging/log.hpp>
-#include <vector>
-#include <variant>
#include <iostream>
+#include <variant>
+#include <vector>
namespace ipmi
{
@@ -55,7 +54,6 @@
uint8_t interface, uint2_t lun, uint6_t netFnReq,
uint8_t cmdReq, SecureBuffer data)
{
-
ipmi::message::Response::ptr res;
// Updating the correct netfn and cmd in the ipmi Context
@@ -308,7 +306,6 @@
[[maybe_unused]] static void registerBICFunctions(void)
{
-
phosphor::logging::log<phosphor::logging::level::INFO>(
"Registering BIC commands");
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index d781964..118b715 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -16,30 +16,28 @@
*/
#include "xyz/openbmc_project/Common/error.hpp"
-#include <xyz/openbmc_project/Control/Boot/Mode/server.hpp>
-#include <xyz/openbmc_project/Control/Boot/Source/server.hpp>
-#include <xyz/openbmc_project/Control/Boot/Type/server.hpp>
+#include <commandutils.hpp>
+#include <ipmid/api-types.hpp>
#include <ipmid/api.hpp>
#include <ipmid/utils.hpp>
-#include <commandutils.hpp>
#include <nlohmann/json.hpp>
#include <oemcommands.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
-
-#include <ipmid/api.hpp>
-#include <ipmid/api-types.hpp>
+#include <xyz/openbmc_project/Control/Boot/Mode/server.hpp>
+#include <xyz/openbmc_project/Control/Boot/Source/server.hpp>
+#include <xyz/openbmc_project/Control/Boot/Type/server.hpp>
#include <array>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
+#include <regex>
#include <sstream>
#include <string>
#include <vector>
-#include <regex>
#define SIZE_IANA_ID 3
@@ -130,9 +128,9 @@
for (auto& object : objectTree)
{
- auto variant =
- ipmi::getDbusProperty(bus, object.second.begin()->first,
- object.first, IP_INTERFACE, "Type");
+ auto variant = ipmi::getDbusProperty(bus, object.second.begin()->first,
+ object.first, IP_INTERFACE,
+ "Type");
if (std::get<std::string>(variant) != protocol)
{
continue;
@@ -206,8 +204,8 @@
std::tuple<std::string, std::string> objPath(size_t id)
{
std::string hostName = "host" + std::to_string(id);
- std::string bootObjPath =
- "/xyz/openbmc_project/control/" + hostName + "/boot";
+ std::string bootObjPath = "/xyz/openbmc_project/control/" + hostName +
+ "/boot";
return std::make_tuple(std::move(bootObjPath), std::move(hostName));
}
@@ -841,9 +839,9 @@
auto conn = getSdBus();
/* Get the post codes by calling GetPostCodes method */
- auto msg =
- conn->new_method_call(postCodeService.c_str(), postCodeObjPath.c_str(),
- postCodeInterface, "GetPostCodes");
+ auto msg = conn->new_method_call(postCodeService.c_str(),
+ postCodeObjPath.c_str(), postCodeInterface,
+ "GetPostCodes");
msg.append(lastestPostCodeIndex);
try
@@ -895,8 +893,8 @@
std::string bootOption =
sdbusplus::message::convert_to_string<boot::BootMode>(bootValue);
- std::string service =
- getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath);
+ std::string service = getService(*dbus, ipmi::boot::bootModeIntf,
+ bootObjPath);
setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf,
ipmi::boot::bootModeProp, bootOption);
@@ -957,7 +955,6 @@
ipmi::RspType<std::vector<uint8_t>>
ipmiOemSetBootOrder(ipmi::Context::ptr ctx, std::vector<uint8_t> data)
{
-
uint8_t bootSeq[SIZE_BOOT_ORDER];
size_t len = data.size();
@@ -1007,11 +1004,11 @@
// GETTING PROPERTY OF MODE INTERFACE
- std::string service =
- getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath);
- Value variant =
- getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf,
- ipmi::boot::bootModeProp);
+ std::string service = getService(*dbus, ipmi::boot::bootModeIntf,
+ bootObjPath);
+ Value variant = getDbusProperty(*dbus, service, bootObjPath,
+ ipmi::boot::bootModeIntf,
+ ipmi::boot::bootModeProp);
auto bootMode = sdbusplus::message::convert_from_string<boot::BootMode>(
std::get<std::string>(variant));
@@ -1021,18 +1018,18 @@
// GETTING PROPERTY OF TYPE INTERFACE
service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath);
- variant =
- getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf,
- ipmi::boot::bootTypeProp);
+ variant = getDbusProperty(*dbus, service, bootObjPath,
+ ipmi::boot::bootTypeIntf,
+ ipmi::boot::bootTypeProp);
auto bootType = sdbusplus::message::convert_from_string<boot::BootType>(
std::get<std::string>(variant));
// Get the valid bit from boot enabled property
service = getService(*dbus, ipmi::boot::bootEnableIntf, bootObjPath);
- variant =
- getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootEnableIntf,
- ipmi::boot::bootEnableProp);
+ variant = getDbusProperty(*dbus, service, bootObjPath,
+ ipmi::boot::bootEnableIntf,
+ ipmi::boot::bootEnableProp);
bool validFlag = std::get<bool>(variant);
@@ -1297,7 +1294,6 @@
if (reqData.size() != GUID_SIZE) // 16bytes
{
-
return ipmi::responseReqDataLenInvalid();
}
diff --git a/src/selcommands.cpp b/src/selcommands.cpp
index d4af84f..c6f0c9b 100644
--- a/src/selcommands.cpp
+++ b/src/selcommands.cpp
@@ -260,7 +260,6 @@
static void logCritIrq(uint8_t* data, std::string& errLog)
{
-
if (data[0] == 0x0)
{
errLog = "NMI / Diagnostic Interrupt";
@@ -279,7 +278,6 @@
static void logPostErr(uint8_t* data, std::string& errLog)
{
-
if ((data[0] & 0x0F) == 0x0)
{
errLog = "System Firmware Error";
@@ -296,8 +294,8 @@
}
else if (((data[0] >> 6) & 0x03) == 0x2)
{
- errLog +=
- ", OEM Post Code 0x" + byteToStr(data[2]) + byteToStr(data[1]);
+ errLog += ", OEM Post Code 0x" + byteToStr(data[2]) +
+ byteToStr(data[1]);
switch ((data[2] << 8) | data[1])
{
@@ -484,7 +482,6 @@
{
case 0x0:
{
-
/* All Info Valid */
[[maybe_unused]] uint8_t chnNum = (data[2] & 0x1C) >> 2;
[[maybe_unused]] uint8_t dimmNum = data[2] & 0x3;
@@ -531,7 +528,6 @@
static void logPwrErr(uint8_t* data, std::string& errLog)
{
-
if (data[0] == 0x1)
{
errLog = "SYS_PWROK failure";
@@ -552,7 +548,6 @@
static void logCatErr(uint8_t* data, std::string& errLog)
{
-
if (data[0] == 0x0)
{
errLog = "IERR/CATERR";
@@ -757,7 +752,6 @@
static void logNmCap(uint8_t* data, std::string& errLog)
{
-
const std::vector<std::string> nmCapStsStr = {"Not Available", "Available"};
if (data[0] & 0x7) // BIT1=policy, BIT2=monitoring, BIT3=pwr
// limit and the others are reserved
@@ -804,7 +798,6 @@
static void logMSMI(uint8_t* data, std::string& errLog)
{
-
if (data[0] == 0x0)
{
errLog = "IERR/MSMI";
@@ -873,7 +866,6 @@
static void parseSelHelper(StdSELEntry* data, std::string& errStr)
{
-
/* Check if sensor type is OS_BOOT (0x1f) */
if (data->sensorType == 0x1F)
{
@@ -1159,7 +1151,6 @@
static void parseSelData(uint8_t fruId, std::vector<uint8_t>& reqData,
std::string& msgLog)
{
-
/* Get record type */
int recType = reqData[2];
std::string errType, errLog;
@@ -1265,8 +1256,8 @@
{
errType = unknownErr;
toHexStr(reqData, errLog);
- msgLog +=
- errType + " (0x" + recTypeStream.str() + ") RawData: " + errLog;
+ msgLog += errType + " (0x" + recTypeStream.str() +
+ ") RawData: " + errLog;
}
}
@@ -1289,7 +1280,6 @@
uint8_t> // operation support
ipmiStorageGetSELInfo()
{
-
fb_oem::ipmi::sel::GetSELInfoData info;
selObj.getInfo(info);
@@ -1301,7 +1291,6 @@
ipmi::RspType<uint16_t, std::vector<uint8_t>>
ipmiStorageGetSELEntry(std::vector<uint8_t> data)
{
-
if (data.size() != sizeof(fb_oem::ipmi::sel::GetSELEntryRequest))
{
return ipmi::responseReqDataLenInvalid();
@@ -1407,8 +1396,8 @@
fb_oem::ipmi::sel::parseSelData((ctx->hostIdx + 1), data, logErr);
static const std::string openBMCMessageRegistryVersion("0.1");
- std::string messageID =
- "OpenBMC." + openBMCMessageRegistryVersion + ".SELEntryAdded";
+ std::string messageID = "OpenBMC." + openBMCMessageRegistryVersion +
+ ".SELEntryAdded";
/* Log the Raw SEL message to the journal */
std::string journalMsg = "SEL Entry Added: " + ipmiRaw;
diff --git a/src/storagecommands.cpp b/src/storagecommands.cpp
index 1b69e68..f99480d 100644
--- a/src/storagecommands.cpp
+++ b/src/storagecommands.cpp
@@ -25,9 +25,9 @@
#include <sdbusplus/timer.hpp>
#include <sensorutils.hpp>
#include <storagecommands.hpp>
-#include <unordered_map>
#include <iostream>
+#include <unordered_map>
namespace ipmi
{
@@ -410,7 +410,6 @@
if (fruCache.size() >= sizeof(FRUHeader))
{
-
FRUHeader* header = reinterpret_cast<FRUHeader*>(fruCache.data());
size_t lastRecordStart = std::max(
@@ -501,34 +500,31 @@
return IPMI_CC_RESPONSE_ERROR;
}
boost::container::flat_map<std::string, DbusVariant>* fruData = nullptr;
- auto fru =
- std::find_if(frus.begin(), frus.end(),
- [bus, address, &fruData](ManagedEntry& entry) {
- auto findFruDevice =
- entry.second.find("xyz.openbmc_project.FruDevice");
- if (findFruDevice == entry.second.end())
- {
- return false;
- }
- fruData = &(findFruDevice->second);
- auto findBus = findFruDevice->second.find("BUS");
- auto findAddress =
- findFruDevice->second.find("ADDRESS");
- if (findBus == findFruDevice->second.end() ||
- findAddress == findFruDevice->second.end())
- {
- return false;
- }
- if (std::get<uint32_t>(findBus->second) != bus)
- {
- return false;
- }
- if (std::get<uint32_t>(findAddress->second) != address)
- {
- return false;
- }
- return true;
- });
+ auto fru = std::find_if(frus.begin(), frus.end(),
+ [bus, address, &fruData](ManagedEntry& entry) {
+ auto findFruDevice = entry.second.find("xyz.openbmc_project.FruDevice");
+ if (findFruDevice == entry.second.end())
+ {
+ return false;
+ }
+ fruData = &(findFruDevice->second);
+ auto findBus = findFruDevice->second.find("BUS");
+ auto findAddress = findFruDevice->second.find("ADDRESS");
+ if (findBus == findFruDevice->second.end() ||
+ findAddress == findFruDevice->second.end())
+ {
+ return false;
+ }
+ if (std::get<uint32_t>(findBus->second) != bus)
+ {
+ return false;
+ }
+ if (std::get<uint32_t>(findAddress->second) != address)
+ {
+ return false;
+ }
+ return true;
+ });
if (fru == frus.end())
{
return IPMI_CC_RESPONSE_ERROR;
@@ -834,8 +830,8 @@
req->bytesToRead = sizeof(get_sdr::SensorDataFullRecord) - req->offset;
}
- *dataLen =
- 2 + req->bytesToRead; // bytesToRead + MSB and LSB of next record id
+ *dataLen = 2 +
+ req->bytesToRead; // bytesToRead + MSB and LSB of next record id
std::memcpy(&resp->record_data, (char*)&record + req->offset,
req->bytesToRead);
diff --git a/src/usb-dbg.cpp b/src/usb-dbg.cpp
index 4ec6a3d..33584c4 100644
--- a/src/usb-dbg.cpp
+++ b/src/usb-dbg.cpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <usb-dbg.hpp>
#include <commandutils.hpp>
+#include <usb-dbg.hpp>
namespace ipmi
{
@@ -48,11 +48,11 @@
try
{
std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
- std::string service =
- getService(*dbus, ipmi::selector::interface, ipmi::selector::path);
- Value variant =
- getDbusProperty(*dbus, service, ipmi::selector::path,
- ipmi::selector::interface, "MaxPosition");
+ std::string service = getService(*dbus, ipmi::selector::interface,
+ ipmi::selector::path);
+ Value variant = getDbusProperty(*dbus, service, ipmi::selector::path,
+ ipmi::selector::interface,
+ "MaxPosition");
maxPosition = std::get<size_t>(variant);
}
catch (const std::exception& e)
@@ -68,8 +68,8 @@
try
{
std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
- std::string service =
- getService(*dbus, ipmi::selector::interface, ipmi::selector::path);
+ std::string service = getService(*dbus, ipmi::selector::interface,
+ ipmi::selector::path);
Value variant = getDbusProperty(*dbus, service, ipmi::selector::path,
ipmi::selector::interface, "Position");
hostPosition = std::get<size_t>(variant);
@@ -507,8 +507,8 @@
{
if (postObj.size() != phase)
{
- std::string nextPhaseStr =
- "Phase" + std::to_string(phase + 1);
+ std::string nextPhaseStr = "Phase" +
+ std::to_string(phase + 1);
postCode = postObj[nextPhaseStr][0][0];
*next = stoul(postCode, nullptr, 16);
*end = 0;
@@ -751,8 +751,8 @@
senStr += unitStr;
std::string thresholdStr;
- int ret =
- ipmi::storage::getSensorThreshold(senName, thresholdStr);
+ int ret = ipmi::storage::getSensorThreshold(senName,
+ thresholdStr);
if (ret < 0)
{
phosphor::logging::log<phosphor::logging::level::ERR>(