]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
battery-util: debug log when we're unsure about the battery level
authorMike Yuan <me@yhndnzj.com>
Fri, 9 Jun 2023 16:30:41 +0000 (00:30 +0800)
committerLennart Poettering <lennart@poettering.net>
Fri, 9 Jun 2023 20:00:34 +0000 (22:00 +0200)
src/shared/battery-util.c

index 948a5e3b9d6a4216f8a63ed1c0647a6e8b97c82b..43d72f9db751303b928109d80d5a8fa5d35ff4e4 100644 (file)
@@ -267,13 +267,11 @@ int battery_is_discharging_and_low(void) {
         }
 
         /* If we found a battery whose state we couldn't read, don't assume we are in low battery state */
-        if (unsure)
+        if (unsure) {
+                log_debug("Found battery with unreadable state, assuming not in low battery state.");
                 return false;
+        }
 
-        /* Found no charged battery, but did find low batteries */
-        if (found_low)
-                return true;
-
-        /* Found neither charged nor low batteries? let's return that we aren't on low battery state */
-        return false;
+        /* If found neither charged nor low batteries, assume that we aren't in low battery state */
+        return found_low;
 }