]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-util: minor cleanups for on_ac_power()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 27 Aug 2022 06:44:17 +0000 (15:44 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 28 Aug 2022 20:46:45 +0000 (21:46 +0100)
Follow-ups for #24420.

src/shared/udev-util.c

index 2845e62c79cd714cd05fd787a24ce51e2b92d5ee..3c1a674f579bb84b98f04edbed4de7c1abea881d 100644 (file)
@@ -702,13 +702,13 @@ int on_ac_power(void) {
                         }
                 }
 
-                bool is_battery = streq(val, "Battery");
-                if (is_battery) {
+                if (streq(val, "Battery")) {
                         r = sd_device_get_sysattr_value(d, "scope", &val);
-                        if (r < 0)
-                                log_device_debug_errno(d, r, "Failed to read 'scope' sysfs attribute, ignoring: %m");
-                        else if (streq(val, "Device")) {
-                                log_device_debug(d, "The power supply is a device battery, ignoring.");
+                        if (r < 0) {
+                                if (r != -ENOENT)
+                                        log_device_debug_errno(d, r, "Failed to read 'scope' sysfs attribute, ignoring: %m");
+                        } else if (streq(val, "Device")) {
+                                log_device_debug(d, "The power supply is a device battery, ignoring device.");
                                 continue;
                         }
 
@@ -719,7 +719,7 @@ int on_ac_power(void) {
 
                 r = device_get_sysattr_unsigned(d, "online", NULL);
                 if (r < 0) {
-                        log_device_debug_errno(d, r, "Failed to query 'online' sysfs attribute: %m");
+                        log_device_debug_errno(d, r, "Failed to query 'online' sysfs attribute, ignoring device: %m");
                         continue;
                 } else if (r > 0)  /* At least 1 and 2 are defined as different types of 'online' */
                         found_ac_online = true;