mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-26 13:55:34 +00:00
Info window: Fixed attribute values not being rendered properly.
Fixed examples.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,bugprone-*,cppcoreguidelines-*,clang-analyzer-*,misc-*,performance-*,readability-*-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-readability-function-size,-readability-simplify-boolean-expr,-cppcoreguidelines-pro-type-cstyle-cast,-performance-inefficient-string-concatenation,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-vararg,-cppguidelines-pro-bounds-pointer-arithmetic,-cppguidelines-pro-bounds-constant-array-index'
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,bugprone-*,cppcoreguidelines-*,clang-analyzer-*,misc-*,performance-*,readability-*-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-readability-function-size,-readability-simplify-boolean-expr,-cppcoreguidelines-pro-type-cstyle-cast,-performance-inefficient-string-concatenation,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: true
|
||||
|
||||
@@ -50,15 +50,12 @@ Use std::from_chars() in string_is_numeric_impl_classic_locale() (gcc 8)
|
||||
|
||||
std::string setters -> no const&, use std::move.
|
||||
same for std::vector
|
||||
switch -> static const std::map
|
||||
for iter -> for auto
|
||||
push_back -> static vector
|
||||
Should StorageProperty contain also value_uinteger?
|
||||
|
||||
Check TODOs
|
||||
|
||||
Test with clang-tidy
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1773,73 +1773,75 @@ WarningLevel storage_property_autoset_warning(StorageProperty& p)
|
||||
|
||||
case StorageProperty::SubSection::devstat:
|
||||
{
|
||||
const auto& statistic = p.get_value<StorageStatistic>();
|
||||
if (p.is_value_type<StorageStatistic>()) {
|
||||
const auto& statistic = p.get_value<StorageStatistic>();
|
||||
|
||||
if (name_match(p, "Pending Error Count") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
if (name_match(p, "Pending Error Count") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
|
||||
// "Workload Utilization" is either normalized, or encodes several values, so we can't use it.
|
||||
/*
|
||||
} else if (name_match(p, "Workload Utilization") && statistic.value_int >= 50) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive has less than half of its estimated life left.";
|
||||
// "Workload Utilization" is either normalized, or encodes several values, so we can't use it.
|
||||
/*
|
||||
} else if (name_match(p, "Workload Utilization") && statistic.value_int >= 50) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive has less than half of its estimated life left.";
|
||||
|
||||
} else if (name_match(p, "Workload Utilization") && statistic.value_int >= 100) {
|
||||
w = WarningLevel::warning;
|
||||
reason = "The drive is past its estimated lifespan.";
|
||||
*/
|
||||
} else if (name_match(p, "Workload Utilization") && statistic.value_int >= 100) {
|
||||
w = WarningLevel::warning;
|
||||
reason = "The drive is past its estimated lifespan.";
|
||||
*/
|
||||
|
||||
} else if (name_match(p, "Utilization Usage Rate") && statistic.value_int >= 50) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive has less than half of its estimated life left.";
|
||||
} else if (name_match(p, "Utilization Usage Rate") && statistic.value_int >= 50) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive has less than half of its estimated life left.";
|
||||
|
||||
} else if (name_match(p, "Utilization Usage Rate") && statistic.value_int >= 100) {
|
||||
w = WarningLevel::warning;
|
||||
reason = "The drive is past its estimated lifespan.";
|
||||
} else if (name_match(p, "Utilization Usage Rate") && statistic.value_int >= 100) {
|
||||
w = WarningLevel::warning;
|
||||
reason = "The drive is past its estimated lifespan.";
|
||||
|
||||
} else if (name_match(p, "Number of Reallocated Logical Sectors") && !statistic.is_normalized() && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
} else if (name_match(p, "Number of Reallocated Logical Sectors") && !statistic.is_normalized() && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
|
||||
} else if (name_match(p, "Number of Reallocated Logical Sectors") && statistic.is_normalized() && statistic.value_int <= 0) {
|
||||
w = WarningLevel::warning;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
} else if (name_match(p, "Number of Reallocated Logical Sectors") && statistic.is_normalized() && statistic.value_int <= 0) {
|
||||
w = WarningLevel::warning;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
|
||||
} else if (name_match(p, "Number of Mechanical Start Failures") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting mechanical errors.";
|
||||
} else if (name_match(p, "Number of Mechanical Start Failures") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting mechanical errors.";
|
||||
|
||||
} else if (name_match(p, "Number of Realloc. Candidate Logical Sectors") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
} else if (name_match(p, "Number of Realloc. Candidate Logical Sectors") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
|
||||
} else if (name_match(p, "Number of Reported Uncorrectable Errors") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
} else if (name_match(p, "Number of Reported Uncorrectable Errors") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive is reporting surface errors. This could be an indication of future failures and/or potential data loss in bad sectors.";
|
||||
|
||||
} else if (name_match(p, "Current Temperature") && statistic.value_int > 50) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The temperature of the drive is higher than 50 degrees Celsius. "
|
||||
"This may shorten its lifespan and cause damage under severe load. Please install a cooling solution.";
|
||||
} else if (name_match(p, "Current Temperature") && statistic.value_int > 50) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The temperature of the drive is higher than 50 degrees Celsius. "
|
||||
"This may shorten its lifespan and cause damage under severe load. Please install a cooling solution.";
|
||||
|
||||
} else if (name_match(p, "Time in Over-Temperature") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The temperature of the drive is or was over the manufacturer-specified maximum. "
|
||||
"This may have shortened its lifespan and caused damage. Please install a cooling solution.";
|
||||
} else if (name_match(p, "Time in Over-Temperature") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The temperature of the drive is or was over the manufacturer-specified maximum. "
|
||||
"This may have shortened its lifespan and caused damage. Please install a cooling solution.";
|
||||
|
||||
} else if (name_match(p, "Time in Under-Temperature") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The temperature of the drive is or was under the manufacturer-specified minimum. "
|
||||
"This may have shortened its lifespan and caused damage. Please operate the drive within manufacturer-specified temperature range.";
|
||||
} else if (name_match(p, "Time in Under-Temperature") && statistic.value_int > 0) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The temperature of the drive is or was under the manufacturer-specified minimum. "
|
||||
"This may have shortened its lifespan and caused damage. Please operate the drive within manufacturer-specified temperature range.";
|
||||
|
||||
} else if (name_match(p, "Percentage Used Endurance Indicator") && statistic.value_int >= 50) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive has less than half of its estimated life left.";
|
||||
} else if (name_match(p, "Percentage Used Endurance Indicator") && statistic.value_int >= 50) {
|
||||
w = WarningLevel::notice;
|
||||
reason = "The drive has less than half of its estimated life left.";
|
||||
|
||||
} else if (name_match(p, "Percentage Used Endurance Indicator") && statistic.value_int >= 100) {
|
||||
w = WarningLevel::warning;
|
||||
reason = "The drive is past its estimated lifespan.";
|
||||
} else if (name_match(p, "Percentage Used Endurance Indicator") && statistic.value_int >= 100) {
|
||||
w = WarningLevel::warning;
|
||||
reason = "The drive is past its estimated lifespan.";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -45,20 +45,17 @@ int main()
|
||||
std::cerr << hz::format_size(uint64_t(1000204886016ULL), true) << "\n"; // common size of 1 TiB hdd in decimal
|
||||
|
||||
|
||||
using namespace std::literals;
|
||||
using days = std::chrono::duration<int, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>;
|
||||
|
||||
const uint64_t min_size = 60;
|
||||
const uint64_t hour_size = min_size * 60;
|
||||
const uint64_t day_size = hour_size * 24;
|
||||
|
||||
std::cerr << hz::format_time_length(5) << "\n"; // 5 sec
|
||||
std::cerr << hz::format_time_length(uint64_t(5.5 * min_size)) << "\n"; // 5.5 min
|
||||
std::cerr << hz::format_time_length(130 * min_size) << "\n"; // 130 min
|
||||
std::cerr << hz::format_time_length(uint64_t(5.5 * hour_size)) << "\n"; // 5.5 hours
|
||||
std::cerr << hz::format_time_length(uint64_t(24.33 * hour_size)) << "\n"; // 24 hours, 20 minutes
|
||||
std::cerr << hz::format_time_length(130 * hour_size + 30 * min_size) << "\n"; // 130.5 hours
|
||||
std::cerr << hz::format_time_length(5 * day_size + 15 * hour_size + 30 * min_size) << "\n"; // 5 days, 15 hours, 30 minutes
|
||||
std::cerr << hz::format_time_length(20 * day_size - 8 * hour_size) << "\n"; // 19 days, 16 hours
|
||||
|
||||
std::cerr << hz::format_time_length(5s) << "\n"; // 5 sec
|
||||
std::cerr << hz::format_time_length(5min + 30s) << "\n"; // 5.5 min
|
||||
std::cerr << hz::format_time_length(130min) << "\n"; // 130 min
|
||||
std::cerr << hz::format_time_length(5h + 30min) << "\n"; // 5.5 hours
|
||||
std::cerr << hz::format_time_length(24h + 20min) << "\n"; // 24 hours, 20 minutes
|
||||
std::cerr << hz::format_time_length(130h + 30min) << "\n"; // 130.5 hours
|
||||
std::cerr << hz::format_time_length(days(5) + 15h + 30min) << "\n"; // 5 days, 15 hours, 30 minutes
|
||||
std::cerr << hz::format_time_length(days(20) - 8h) << "\n"; // 19 days, 16 hours
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -376,7 +376,14 @@ namespace internal {
|
||||
ss << std::setfill('0') << std::internal << std::setw(static_cast<int>((sizeof(T) * 2) + 2));
|
||||
}
|
||||
|
||||
ss << std::showbase << std::setbase(base) << number;
|
||||
ss << std::showbase << std::setbase(base);
|
||||
|
||||
if constexpr(std::is_same_v<char, T> || std::is_same_v<signed char, T> || std::is_same_v<unsigned char, T>
|
||||
|| std::is_same_v<char16_t, T> || std::is_same_v<char32_t, T> || std::is_same_v<wchar_t, T>) {
|
||||
ss << static_cast<int>(number); // avoid printing them as characters
|
||||
} else {
|
||||
ss << number;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -265,8 +265,8 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AM_CPPFLAGS = $(all_includes)
|
||||
METASOURCES = AUTO
|
||||
noinst_HEADERS = picojson.h
|
||||
noinst_DATA = picojson_version.txt
|
||||
noinst_HEADERS = json.hpp
|
||||
noinst_DATA = LICENSE.MIT json_version.txt
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
debug_set_enabled("dom", debug_level::dump, false);
|
||||
debug_set_format("dom", debug_level::info,
|
||||
(!debug_get_formats("dom")[debug_level::info].none() & !debug_format::color) | debug_format::datetime);
|
||||
(!debug_get_formats("dom")[debug_level::info].none() & ~debug_format::color) | debug_format::datetime);
|
||||
|
||||
|
||||
std::string something = "some thing";
|
||||
|
||||
Reference in New Issue
Block a user