From 86a775b3cacf647f8858613e52e6152774a3eb4e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 17 Apr 2026 14:32:25 +1000 Subject: [PATCH] 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 Part-of: --- tools/libinput-debug-tablet.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/libinput-debug-tablet.c b/tools/libinput-debug-tablet.c index 2848dc64..5e074261 100644 --- a/tools/libinput-debug-tablet.c +++ b/tools/libinput-debug-tablet.c @@ -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; }