ecore_drm: Don't crash if a device is assigned a bad output
authorDerek Foreman <derekf@osg.samsung.com>
Wed, 22 Apr 2015 18:32:16 +0000 (14:32 -0400)
committerChris Michael <cp.michael@samsung.com>
Wed, 22 Apr 2015 18:32:16 +0000 (14:32 -0400)
Summary:
If an input device is assigned via udev to an output that we can't find
we just assign it to the first output instead.

Reviewers: zmike, devilhorns

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2408

src/lib/ecore_drm/ecore_drm_evdev.c

index 9f4651649a8333288598721907599858c9a4d28c..04275fdb70ecda9e8a6c788eb13c8c30cc8409b7 100644 (file)
@@ -65,20 +65,16 @@ _device_output_set(Ecore_Drm_Evdev *edev)
         DBG("Device Has Output Name: %s", oname);
 
         EINA_LIST_FOREACH(input->dev->outputs, l, output)
-          {
-             if ((output->name) && (!strcmp(output->name, oname)))
-               {
-                  edev->output = output;
-                  break;
-               }
-          }
-     }
-   else
-     {
-        if (!(output = eina_list_nth(input->dev->outputs, 0))) return;
-        edev->output = output;
+          if ((output->name) && (!strcmp(output->name, oname))) break;
      }
 
+   if (!output)
+     output = eina_list_nth(input->dev->outputs, 0);
+
+   if (!output) return;
+
+   edev->output = output;
+
    if (libinput_device_has_capability(edev->device, 
                                       LIBINPUT_DEVICE_CAP_POINTER))
      {