TaskBar: Prevent possible division by zero
If battery reports its full capacity as zero, battery percentage calculation did a division by zero crashing the TaskBar :)
This commit is contained in:
parent
3a6cdfff45
commit
a7f3351c0e
|
@ -38,7 +38,7 @@ static BAN::String get_battery_percentage()
|
|||
|
||||
sprintf(buffer, "/dev/batteries/%s/capacity_full", dirent->d_name);
|
||||
auto cap_full = read_integer_from_file(buffer);
|
||||
if (cap_full.is_error())
|
||||
if (cap_full.is_error() || cap_full.value() == 0)
|
||||
continue;
|
||||
|
||||
sprintf(buffer, "/dev/batteries/%s/capacity_now", dirent->d_name);
|
||||
|
|
Loading…
Reference in New Issue