diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-08-27 15:44:17 +0900 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2022-08-28 21:46:45 +0100 |
commit | 8676bdb70842ebb8d55fcc50774ba69f8a14b51a (patch) | |
tree | 9b2ad204109019a21ac9f0e057113bf9936eb658 | |
parent | 704b0d8464b5fd70e5439b735e542a19894aad2f (diff) | |
download | systemd-8676bdb70842ebb8d55fcc50774ba69f8a14b51a.tar.gz |
udev-util: minor cleanups for on_ac_power()
Follow-ups for #24420.
-rw-r--r-- | src/shared/udev-util.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index 2845e62c79..3c1a674f57 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -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; |