chiark / gitweb /
logind: Do not fail display count if a device has no parent
authorMantas Mikulėnas <grawity@gmail.com>
Tue, 11 Mar 2014 15:49:00 +0000 (17:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 11 Mar 2014 16:45:24 +0000 (17:45 +0100)
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
src/login/logind-core.c

index ae7b35055a86b48013870b1a6057655ad7c1cfc2..1928f43cd1c314191f872f21340466adac039734 100644 (file)
@@ -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;
                 }
index ca34d378ff02fdffdf0c98b93dbce61f7cba08ac..053d2ed63e189df1cfec0c53e8d3093deb672ca7 100644 (file)
@@ -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,