diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-22 13:02:07 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-11-16 15:39:31 +0100 |
commit | e455380b187aab1d02424d342d72c7cebb2d3bfb (patch) | |
tree | 450868831aae92ba744b54b1dee779ab56f3a12f | |
parent | c30e0d7b6a57d9587ad596b69852256e4e3bf7fb (diff) | |
download | systemd-e455380b187aab1d02424d342d72c7cebb2d3bfb.tar.gz systemd-e455380b187aab1d02424d342d72c7cebb2d3bfb.tar.bz2 systemd-e455380b187aab1d02424d342d72c7cebb2d3bfb.zip |
logind: make sure that if we can't figure out whether we are on AC we presume we are
It's safer to assume that we are on AC than to assume we are on battery,
if we can't figure it out.
-rw-r--r-- | src/login/logind-core.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/login/logind-core.c b/src/login/logind-core.c index 5608486284..2bab2fd2f5 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -681,15 +681,13 @@ bool manager_is_docked_or_external_displays(Manager *m) { bool manager_is_on_external_power(void) { int r; - /* For now we only check for AC power, but 'external power' can apply - * to anything that isn't an internal battery */ + /* For now we only check for AC power, but 'external power' can apply to anything that isn't an internal + * battery */ r = on_ac_power(); if (r < 0) log_warning_errno(r, "Failed to read AC power status: %m"); - else if (r > 0) - return true; - return false; + return r != 0; /* Treat failure as 'on AC' */ } bool manager_all_buttons_ignored(Manager *m) { |