From 94036de887ad5b0dc805abe38b5c1c58b57d9465 Mon Sep 17 00:00:00 2001 From: Mantas Mikulėnas Date: Tue, 11 Mar 2014 17:49:00 +0200 Subject: logind: Do not fail display count if a device has no parent udev_device_get_parent() may return NULL when the device doesn't have a parent, as is the case with (for example) /sys/devices/virtual/drm/ttm. Also, log an actual error message instead of "-12 displays connected". --- src/login/logind-action.c | 4 +++- src/login/logind-core.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/login') diff --git a/src/login/logind-action.c b/src/login/logind-action.c index ae7b35055a..1928f43cd1 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -84,7 +84,9 @@ int manager_handle_action( * treat like this under the assumption that there is * no modern drm driver available. */ n = manager_count_displays(m); - if (n != 1) { + if (n < 0) + log_warning("Display counting failed: %s", strerror(-n)); + else if (n != 1) { log_debug("Ignoring lid switch request, %i displays connected.", n); return 0; } diff --git a/src/login/logind-core.c b/src/login/logind-core.c index ca34d378ff..053d2ed63e 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -520,7 +520,7 @@ int manager_count_displays(Manager *m) { p = udev_device_get_parent(d); if (!p) - return -ENOMEM; + continue; /* If the parent shares the same subsystem as the * device we are looking at then it is a connector, -- cgit v1.2.3-54-g00ecf