From: Lennart Poettering Date: Mon, 22 Oct 2018 11:02:07 +0000 (+0200) Subject: logind: make sure that if we can't figure out whether we are on AC we presume we are X-Git-Tag: v240~306^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e455380b187aab1d02424d342d72c7cebb2d3bfb;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/login/logind-core.c b/src/login/logind-core.c index 5608486284b..2bab2fd2f5f 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) {