From b54a557e7655e6cd98493d216f33a5ce681b910c Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Thu, 27 Jun 2024 01:26:57 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20gucc:=20refactor=20with=20clang-?= =?UTF-8?q?tidy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gucc/src/cpu.cpp | 12 +++++++----- gucc/src/zfs.cpp | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gucc/src/cpu.cpp b/gucc/src/cpu.cpp index 2072f99..9279bd6 100644 --- a/gucc/src/cpu.cpp +++ b/gucc/src/cpu.cpp @@ -11,6 +11,7 @@ namespace gucc::cpu { /* clang-format off */ namespace { +// NOLINTBEGIN static uint64_t xgetbv() noexcept { uint32_t eax{}; uint32_t edx{}; @@ -106,6 +107,7 @@ static int32_t get_cpu_features() noexcept { return 0; #endif } +// NOLINTEND } // namespace /* clang-format on */ @@ -114,9 +116,9 @@ auto get_isa_levels() noexcept -> std::vector { std::vector supported_isa_levels; { - struct utsname un; + struct utsname un{}; uname(&un); - supported_isa_levels.push_back(std::string{un.machine}); + supported_isa_levels.emplace_back(un.machine); } const int32_t features = get_cpu_features(); @@ -125,21 +127,21 @@ auto get_isa_levels() noexcept -> std::vector { const bool supports_v2 = (features & SSSE3) && (features & SSE41) && (features & SSE42); if (supports_v2) { spdlog::info("cpu supports x86_64_v2"); - supported_isa_levels.push_back("x86_64_v2"); + supported_isa_levels.emplace_back("x86_64_v2"); } /* Check for x86_64_v3 */ const bool supports_v3 = (supports_v2) && (features & AVX) && (features & AVX2); if (supports_v3) { spdlog::info("cpu supports x86_64_v3"); - supported_isa_levels.push_back("x86_64_v3"); + supported_isa_levels.emplace_back("x86_64_v3"); } /* Check for x86_64_v4 */ const bool supports_v4 = (supports_v3) && (features & AVX512F) && (features & AVX512VL) && (features & AVX512BW) && (features & AVX512CD) && (features & AVX512DQ); if (supports_v4) { spdlog::info("cpu supports x86_64_v4"); - supported_isa_levels.push_back("x86_64_v4"); + supported_isa_levels.emplace_back("x86_64_v4"); } return supported_isa_levels; diff --git a/gucc/src/zfs.cpp b/gucc/src/zfs.cpp index 5b61f16..68eeacf 100644 --- a/gucc/src/zfs.cpp +++ b/gucc/src/zfs.cpp @@ -40,7 +40,7 @@ void zfs_destroy_dataset(std::string_view zdataset) noexcept { // returns a list of imported zpools auto zfs_list_pools() noexcept -> std::string { #ifdef NDEVENV - return utils::exec("zfs list -H -o name 2>/dev/null | grep \"/\""sv); + return utils::exec(R"(zfs list -H -o name 2>/dev/null | grep "/")"sv); #else return {"vol0\nvol1\n"}; #endif @@ -50,8 +50,8 @@ auto zfs_list_pools() noexcept -> std::string { auto zfs_list_devs() noexcept -> std::string { std::string list_of_devices{}; // get a list of devices with zpools on them - const auto& devices = utils::make_multiline(utils::exec("zpool status -PL 2>/dev/null | awk '{print $1}' | grep \"^/\""sv)); - for (const auto& device : devices) { + auto devices = utils::make_multiline(utils::exec(R"(zpool status -PL 2>/dev/null | awk '{print $1}' | grep "^/")"sv)); + for (auto&& device : std::move(devices)) { // add the device list_of_devices += fmt::format(FMT_COMPILE("{}\n"), device); // now let's add any other forms of those devices @@ -65,10 +65,10 @@ auto zfs_list_datasets(std::string_view type) noexcept -> std::string { if (type == "zvol"sv) { return utils::exec("zfs list -Ht volume -o name,volsize 2>/dev/null"sv); } else if (type == "legacy"sv) { - return utils::exec("zfs list -Ht filesystem -o name,mountpoint 2>/dev/null | grep \"^.*/.*legacy$\" | awk '{print $1}'"sv); + return utils::exec(R"(zfs list -Ht filesystem -o name,mountpoint 2>/dev/null | grep "^.*/.*legacy$" | awk '{print $1}')"sv); } - return utils::exec("zfs list -H -o name 2>/dev/null | grep \"/\""sv); + return utils::exec(R"(zfs list -H -o name 2>/dev/null | grep "/")"sv); #else spdlog::debug("type := {}", type); return {"zpcachyos"};