diff --git a/src/libeis-device.c b/src/libeis-device.c index ef3ebe9..9a46c61 100644 --- a/src/libeis-device.c +++ b/src/libeis-device.c @@ -384,26 +384,42 @@ eis_device_add(struct eis_device *device) eis_client_register_object(client, &device->proto_object); eis_seat_event_device(seat, device->proto_object.id, device->proto_object.version); int rc = eis_device_event_name(device, device->name); - if (rc == 0) - rc = eis_device_event_capabilities(device, device->capabilities); - if (rc == 0) - rc = eis_device_event_type(device, device->type); - if (rc == 0 && device->type == EIS_DEVICE_TYPE_PHYSICAL) + if (rc < 0) + goto out; + + rc = eis_device_event_capabilities(device, device->capabilities); + if (rc < 0) + goto out; + + rc = eis_device_event_type(device, device->type); + if (rc < 0) + goto out; + + if (device->type == EIS_DEVICE_TYPE_PHYSICAL) { rc = eis_device_event_dimensions(device, device->width, device->height); - if (rc == 0 &&device->type == EIS_DEVICE_TYPE_VIRTUAL) { + if (rc < 0) + goto out; + } + if (device->type == EIS_DEVICE_TYPE_VIRTUAL) { struct eis_region *r; list_for_each(r, &device->regions, link) { rc = eis_device_event_region(device, r->x, r->y, r->width, r->height, r->physical_scale); - if (rc != 0) - break; + if (rc < 0) + goto out; } } - if (rc >= 0 && device->keymap) - rc = eis_device_event_keymap(device, device->keymap->type, device->keymap->size, device->keymap->fd); - if (rc == 0) - eis_device_event_done(device); + if (device->keymap) { + rc = eis_device_event_keymap(device, device->keymap->type, device->keymap->size, device->keymap->fd); + if (rc < 0) + goto out; + } + rc = eis_device_event_done(device); + if (rc < 0) + goto out; +out: /* FIXME: check rc */ + return; } _public_ void