xkb: Don't call exit on failure in weston_compositor_xkb_init()
authorKristian Høgsberg <krh@bitplanet.net>
Sat, 16 Feb 2013 19:29:24 +0000 (14:29 -0500)
committerJonas Ådahl <jadahl@gmail.com>
Sun, 10 Nov 2013 16:51:31 +0000 (17:51 +0100)
This will exit without cleaning vt modes and leave the system stuck.

https://bugs.freedesktop.org/show_bug.cgi?id=60817

src/evdev.c
src/evdev.h

index 0b99c43649b76428fd8cc853a35ad8635b53ec17..286543a0aa43549c27a1ec8b376c44f8964d83a4 100644 (file)
@@ -397,7 +397,7 @@ evdev_device_data(int fd, uint32_t mask, void *data)
 }
 
 static int
-evdev_configure_device(struct evdev_device *device)
+evdev_handle_device(struct evdev_device *device)
 {
        struct input_absinfo absinfo;
        unsigned long ev_bits[NBITS(EV_MAX)];
@@ -483,9 +483,15 @@ evdev_configure_device(struct evdev_device *device)
                weston_log("input device %s, %s "
                           "ignored: unsupported device type\n",
                           device->devname, device->devnode);
-               return -1;
+               return 0;
        }
 
+       return 1;
+}
+
+static int
+evdev_configure_device(struct evdev_device *device)
+{
        if ((device->caps &
             (EVDEV_MOTION_ABS | EVDEV_MOTION_REL | EVDEV_BUTTON))) {
                weston_seat_init_pointer(device->seat);
@@ -496,7 +502,8 @@ evdev_configure_device(struct evdev_device *device)
                           device->caps & EVDEV_BUTTON ? " button" : "");
        }
        if ((device->caps & EVDEV_KEYBOARD)) {
-               weston_seat_init_keyboard(device->seat, NULL);
+               if (weston_seat_init_keyboard(device->seat, NULL) < 0)
+                       return -1;
                weston_log("input device %s, %s is a keyboard\n",
                           device->devname, device->devnode);
        }
@@ -538,6 +545,13 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd)
        ioctl(device->fd, EVIOCGNAME(sizeof(devname)), devname);
        device->devname = strdup(devname);
 
+       if (!evdev_handle_device(device)) {
+               free(device->devnode);
+               free(device->devname);
+               free(device);
+               return EVDEV_UNHANDLED_DEVICE;
+       }
+
        if (evdev_configure_device(device) == -1)
                goto err1;
 
index a90f90cd341ff8cd71af5096de3b723ebb5ef97d..ccbb22247d086ab40c4bd1c97cdddc99fba40239 100644 (file)
@@ -88,6 +88,8 @@ struct evdev_device {
 #define TEST_BIT(array, bit)    ((array[LONG(bit)] >> OFF(bit)) & 1)
 /* end copied */
 
+#define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
+
 struct evdev_dispatch;
 
 struct evdev_dispatch_interface {