mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 22:42:31 +08:00
🧹 gucc: refactor with clang-tidy
This commit is contained in:
parent
c5d7edb870
commit
b54a557e76
@ -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::string> {
|
||||
std::vector<std::string> 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<std::string> {
|
||||
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;
|
||||
|
@ -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"};
|
||||
|
Loading…
Reference in New Issue
Block a user