clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: I362352dcb341658501899267c2ff3ad044ed5912
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/subprojects/metrics-ipmi-blobs/metric.cpp b/subprojects/metrics-ipmi-blobs/metric.cpp
index 59954c4..bbff3ef 100644
--- a/subprojects/metrics-ipmi-blobs/metric.cpp
+++ b/subprojects/metrics-ipmi-blobs/metric.cpp
@@ -41,15 +41,16 @@
{}
template <typename T>
-static constexpr auto pbEncodeStr = [](pb_ostream_t* stream,
- const pb_field_iter_t* field,
- void* const* arg) noexcept {
- static_assert(sizeof(*std::declval<T>().data()) == sizeof(pb_byte_t));
- const auto& s = *reinterpret_cast<const T*>(*arg);
- return pb_encode_tag_for_field(stream, field) &&
- pb_encode_string(
- stream, reinterpret_cast<const pb_byte_t*>(s.data()), s.size());
-};
+static constexpr auto pbEncodeStr =
+ [](pb_ostream_t* stream, const pb_field_iter_t* field,
+ void* const* arg) noexcept {
+ static_assert(sizeof(*std::declval<T>().data()) == sizeof(pb_byte_t));
+ const auto& s = *reinterpret_cast<const T*>(*arg);
+ return pb_encode_tag_for_field(stream, field) &&
+ pb_encode_string(stream,
+ reinterpret_cast<const pb_byte_t*>(s.data()),
+ s.size());
+ };
template <typename T>
static pb_callback_t pbStrEncoder(const T& t) noexcept
@@ -58,19 +59,19 @@
}
template <auto fields, typename T>
-static constexpr auto pbEncodeSubs = [](pb_ostream_t* stream,
- const pb_field_iter_t* field,
- void* const* arg) noexcept {
- for (const auto& sub : *reinterpret_cast<const std::vector<T>*>(*arg))
- {
- if (!pb_encode_tag_for_field(stream, field) ||
- !pb_encode_submessage(stream, fields, &sub))
+static constexpr auto pbEncodeSubs =
+ [](pb_ostream_t* stream, const pb_field_iter_t* field,
+ void* const* arg) noexcept {
+ for (const auto& sub : *reinterpret_cast<const std::vector<T>*>(*arg))
{
- return false;
+ if (!pb_encode_tag_for_field(stream, field) ||
+ !pb_encode_submessage(stream, fields, &sub))
+ {
+ return false;
+ }
}
- }
- return true;
-};
+ return true;
+ };
template <auto fields, typename T>
static pb_callback_t pbSubsEncoder(const std::vector<T>& t)
diff --git a/subprojects/metrics-ipmi-blobs/test/util_test.cpp b/subprojects/metrics-ipmi-blobs/test/util_test.cpp
index 8a7e181..60c6063 100644
--- a/subprojects/metrics-ipmi-blobs/test/util_test.cpp
+++ b/subprojects/metrics-ipmi-blobs/test/util_test.cpp
@@ -59,10 +59,11 @@
// ticks_per_sec is usually 100 on the BMC
const long ticksPerSec = 100;
- const std::string_view content = "2596 (dbus-broker) R 2577 2577 2577 0 -1 "
- "4194560 299 0 1 0 333037 246110 0 0 20 0 "
- "1 0 1545 3411968 530 4294967295 65536 "
- "246512 2930531712 0 0 0 81923 4";
+ const std::string_view content =
+ "2596 (dbus-broker) R 2577 2577 2577 0 -1 "
+ "4194560 299 0 1 0 333037 246110 0 0 20 0 "
+ "1 0 1545 3411968 530 4294967295 65536 "
+ "246512 2930531712 0 0 0 81923 4";
metric_blob::TcommUtimeStime t =
metric_blob::parseTcommUtimeStimeString(content, ticksPerSec);
@@ -90,13 +91,14 @@
TEST(ParseMeminfoValue, validInput)
{
- const std::string_view content = "MemTotal: 1027040 kB\n"
- "MemFree: 868144 kB\n"
- "MemAvailable: 919308 kB\n"
- "Buffers: 13008 kB\n"
- "Cached: 82840 kB\n"
- "SwapCached: 0 kB\n"
- "Active: 62076 kB\n";
+ const std::string_view content =
+ "MemTotal: 1027040 kB\n"
+ "MemFree: 868144 kB\n"
+ "MemAvailable: 919308 kB\n"
+ "Buffers: 13008 kB\n"
+ "Cached: 82840 kB\n"
+ "SwapCached: 0 kB\n"
+ "Active: 62076 kB\n";
int value;
EXPECT_TRUE(metric_blob::parseMeminfoValue(content, "MemTotal:", value));
EXPECT_EQ(value, 1027040);
diff --git a/subprojects/metrics-ipmi-blobs/util.cpp b/subprojects/metrics-ipmi-blobs/util.cpp
index 0e14698..79d97db 100644
--- a/subprojects/metrics-ipmi-blobs/util.cpp
+++ b/subprojects/metrics-ipmi-blobs/util.cpp
@@ -111,8 +111,8 @@
std::string getCmdLine(const int pid)
{
- const std::string& cmdlinePath = "/proc/" + std::to_string(pid) +
- "/cmdline";
+ const std::string& cmdlinePath =
+ "/proc/" + std::to_string(pid) + "/cmdline";
std::string cmdline = readFileThenGrepIntoString(cmdlinePath);
for (size_t i = 0; i < cmdline.size(); ++i)
@@ -245,8 +245,8 @@
uint32_t pageOffset = target & ~static_cast<uint32_t>(pageSize - 1);
uint32_t offsetInPage = target & static_cast<uint32_t>(pageSize - 1);
- void* mapBase = mmap(NULL, pageSize * 2, PROT_READ, MAP_SHARED, fd,
- pageOffset);
+ void* mapBase =
+ mmap(NULL, pageSize * 2, PROT_READ, MAP_SHARED, fd, pageOffset);
if (mapBase == MAP_FAILED)
{
close(fd);
@@ -326,8 +326,8 @@
return false;
}
- std::string cpuinfo = readFileThenGrepIntoString("/proc/cpuinfo",
- "Hardware");
+ std::string cpuinfo =
+ readFileThenGrepIntoString("/proc/cpuinfo", "Hardware");
// Nuvoton NPCM7XX chip has a counter which starts from power-on.
if (cpuinfo.find("NPCM7XX") != std::string::npos)
{