evdev: Simplify error path for device creation

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
dev
Tiago Vignatti 14 years ago committed by Kristian Høgsberg
parent d9f7d1f0c5
commit ac9cfd3065
  1. 34
      compositor/evdev.c

@ -293,7 +293,7 @@ evdev_input_device_create(struct evdev_input *master,
return NULL; return NULL;
ec = (struct wlsc_compositor *) master->base.input_device.compositor; ec = (struct wlsc_compositor *) master->base.input_device.compositor;
device->output = device->output =
container_of(ec->output_list.next, struct wlsc_output, link); container_of(ec->output_list.next, struct wlsc_output, link);
device->tool = 1; device->tool = 1;
@ -302,33 +302,29 @@ evdev_input_device_create(struct evdev_input *master,
device->devnode = strdup(path); device->devnode = strdup(path);
device->fd = open(path, O_RDONLY); device->fd = open(path, O_RDONLY);
if (device->fd < 0) { if (device->fd < 0)
free(device->devnode); goto err0;
free(device);
fprintf(stderr, "couldn't create pointer for %s: %m\n", path);
return NULL;
}
if (evdev_configure_device(device) == -1) { if (evdev_configure_device(device) == -1)
close(device->fd); goto err1;
free(device->devnode);
free(device);
return NULL;
}
loop = wl_display_get_event_loop(display); loop = wl_display_get_event_loop(display);
device->source = wl_event_loop_add_fd(loop, device->fd, device->source = wl_event_loop_add_fd(loop, device->fd,
WL_EVENT_READABLE, WL_EVENT_READABLE,
evdev_input_device_data, device); evdev_input_device_data, device);
if (device->source == NULL) { if (device->source == NULL)
close(device->fd); goto err1;
free(device->devnode);
free(device);
return NULL;
}
wl_list_insert(master->devices_list.prev, &device->link); wl_list_insert(master->devices_list.prev, &device->link);
return device; return device;
err1:
close(device->fd);
err0:
free(device->devnode);
free(device);
return NULL;
} }
static const char default_seat[] = "seat0"; static const char default_seat[] = "seat0";

Loading…
Cancel
Save