tools/debug-tablet: guard against open() failures

This is a debugging tool so we don't expect NDEBUG but let's handle
errors correctly anyway.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1467>
This commit is contained in:
Peter Hutterer 2026-04-17 14:32:25 +10:00 committed by Marge Bot
parent 0fa334600d
commit 86a775b3ca

View file

@ -277,8 +277,12 @@ handle_device_added(struct context *ctx, struct libinput_event *ev)
devnode = udev_device_get_devnode(udev_device);
if (devnode) {
int fd = open(devnode, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
assert(fd != -1);
assert(libevdev_new_from_fd(fd, &ctx->evdev) == 0);
if (fd == -1)
return;
if (libevdev_new_from_fd(fd, &ctx->evdev) != 0) {
close(fd);
return;
}
ctx->fds[1].fd = fd;
}