]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
battery-util: don't log duplicate message
authorMike Yuan <me@yhndnzj.com>
Wed, 9 Aug 2023 16:13:42 +0000 (00:13 +0800)
committerMike Yuan <me@yhndnzj.com>
Sun, 13 Aug 2023 05:02:57 +0000 (13:02 +0800)
Follow-up for 02f7f8aa4f1d0b7a24ee3cd5685a791771d9ded5

Addresses https://github.com/systemd/systemd/pull/28597#discussion_r1288591215

> this is pretty unnecessary, battery_read_capacity_percentage()
debug logs on its own about this already, in more detailed way?

src/shared/battery-util.c

index 8b7bdc704d2c995c90d2a3339b1f769688b979c8..cc3835f9064ede0c37b41dda6c5e8d1d1eb7404b 100644 (file)
@@ -224,7 +224,7 @@ int battery_read_capacity_percentage(sd_device *dev) {
                 return log_device_debug_errno(dev, r, "Failed to read/parse POWER_SUPPLY_CAPACITY: %m");
 
         if (battery_capacity < 0 || battery_capacity > 100)
-                return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ERANGE), "Invalid battery capacity");
+                return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ERANGE), "Invalid battery capacity: %d", battery_capacity);
 
         return battery_capacity;
 }
@@ -254,7 +254,6 @@ int battery_is_discharging_and_low(void) {
 
                 level = battery_read_capacity_percentage(dev);
                 if (level < 0) {
-                        log_device_debug_errno(dev, level, "Battery capacity is unreadable: %m");
                         unsure = true;
                         continue;
                 }