mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-27 14:25:34 +00:00
Fixed a crash when system locale is set to invalid locale.
Signed-off-by: Alexander Shaduri <ashaduri@gmail.com>
This commit is contained in:
@@ -43,7 +43,12 @@ std::string StorageAttribute::format_raw_value() const
|
||||
// If it's fully a number, format it with commas
|
||||
if (hz::number_to_string(raw_value_int) == raw_value) {
|
||||
std::stringstream ss;
|
||||
ss.imbue(std::locale(""));
|
||||
try {
|
||||
ss.imbue(std::locale(""));
|
||||
}
|
||||
catch (const std::runtime_error& e) {
|
||||
// something is wrong with system locale, can't do anything here.
|
||||
}
|
||||
ss << std::fixed << raw_value_int;
|
||||
return ss.str();
|
||||
}
|
||||
@@ -71,7 +76,12 @@ std::string StorageStatistic::format_value() const
|
||||
// If it's fully a number, format it with commas
|
||||
if (hz::number_to_string(value_int) == value) {
|
||||
std::stringstream ss;
|
||||
ss.imbue(std::locale(""));
|
||||
try {
|
||||
ss.imbue(std::locale(""));
|
||||
}
|
||||
catch (const std::runtime_error& e) {
|
||||
// something is wrong with system locale, can't do anything here.
|
||||
}
|
||||
ss << std::fixed << value_int;
|
||||
return ss.str();
|
||||
}
|
||||
@@ -153,7 +163,12 @@ int StorageErrorBlock::get_warning_level_for_error_type(std::string& type)
|
||||
std::string StorageErrorBlock::format_lifetime_hours() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.imbue(std::locale(""));
|
||||
try {
|
||||
ss.imbue(std::locale(""));
|
||||
}
|
||||
catch (const std::runtime_error& e) {
|
||||
// something is wrong with system locale, can't do anything here.
|
||||
}
|
||||
ss << std::fixed << lifetime_hours;
|
||||
return ss.str();
|
||||
}
|
||||
@@ -173,7 +188,12 @@ std::ostream& operator<< (std::ostream& os, const StorageErrorBlock& b)
|
||||
std::string StorageSelftestEntry::format_lifetime_hours() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.imbue(std::locale(""));
|
||||
try {
|
||||
ss.imbue(std::locale(""));
|
||||
}
|
||||
catch (const std::runtime_error& e) {
|
||||
// something is wrong with system locale, can't do anything here.
|
||||
}
|
||||
ss << std::fixed << lifetime_hours;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user