sleep: do not abort if we try to query capacity of missing battery

Fixes #25584.

From the issue:
Assertion 'capacity >= 0' failed at src/shared/sleep-config.c:58, function PTR_TO_CAPACITY(). Aborting.

(gdb) bt

The problem is that PTR_TO_CAPACITY(hashmap_get(last_capacity, battery_name))
will abort if it's called with a name not present in the hashmap. We want to
skip the device silently in this case instead.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-01-23 22:05:36 +01:00
parent e830d6dd2d
commit 7ebbe4a5ce
+1 -1
View File
@@ -495,7 +495,7 @@ int get_total_suspend_interval(Hashmap *last_capacity, usec_t *ret) {
continue;
}
battery_last_capacity = PTR_TO_CAPACITY(hashmap_get(last_capacity, battery_name));
battery_last_capacity = get_capacity_by_name(last_capacity, battery_name);
if (battery_last_capacity <= 0)
continue;