From 8afdc52eaf87472aa54966d33d132ce5d3a1a418 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 17 Apr 2026 14:19:16 +1000 Subject: [PATCH] tools: Use xclose() over close() Co-Authored-By: Claude Opus 4.6 Part-of: --- tools/libinput-debug-gui.c | 5 +++-- tools/libinput-debug-tablet.c | 4 ++-- tools/libinput-record.c | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c index 36aa9dd6..af41682c 100644 --- a/tools/libinput-debug-gui.c +++ b/tools/libinput-debug-gui.c @@ -40,6 +40,7 @@ #include #include +#include "util-files.h" #include "util-list.h" #include "util-macros.h" #include "util-strings.h" @@ -1358,7 +1359,7 @@ register_evdev_device(struct window *w, struct libinput_device *dev) g_io_add_watch(c, G_IO_IN, handle_event_evdev, d->libinput_device); fd = -1; out: - close(fd); + xclose(&fd); udev_device_unref(ud); } @@ -1376,7 +1377,7 @@ unregister_evdev_device(struct window *w, struct libinput_device *dev) free(libinput_device_get_user_data(d->libinput_device)); libinput_device_unref(d->libinput_device); libevdev_free(d->evdev); - close(d->fd); + xclose(&d->fd); free(d); w->evdev.last_device = 0; break; diff --git a/tools/libinput-debug-tablet.c b/tools/libinput-debug-tablet.c index 0ebc447a..bc8d24f0 100644 --- a/tools/libinput-debug-tablet.c +++ b/tools/libinput-debug-tablet.c @@ -37,6 +37,7 @@ #include #include +#include "util-files.h" #include "util-input-event.h" #include "util-macros.h" #include "util-strings.h" @@ -298,8 +299,7 @@ handle_device_removed(struct context *ctx, struct libinput_event *ev) libevdev_free(ctx->evdev); ctx->evdev = NULL; - close(ctx->fds[1].fd); - ctx->fds[1].fd = -1; + xclose(&ctx->fds[1].fd); } static void diff --git a/tools/libinput-record.c b/tools/libinput-record.c index b3768738..f3e2c0e8 100644 --- a/tools/libinput-record.c +++ b/tools/libinput-record.c @@ -1721,7 +1721,7 @@ print_hid_report_descriptor(struct record_device *dev) iprintf(dev->fp, I_NONE, "\n"); iprintf(dev->fp, I_DEVICE, "]\n"); - close(fd); + xclose(&fd); } static void @@ -2119,7 +2119,7 @@ destroy_source(struct record_context *ctx, struct source *source) { list_remove(&source->link); epoll_ctl(ctx->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL); - close(source->fd); + xclose(&source->fd); free(source); } @@ -2379,7 +2379,7 @@ mainloop(struct record_context *ctx) list_for_each_safe(source, &ctx->sources, link) { destroy_source(ctx, source); } - close(ctx->epoll_fd); + xclose(&ctx->epoll_fd); return 0; } @@ -2799,7 +2799,7 @@ out: struct hidraw *hidraw; list_for_each_safe(hidraw, &d->hidraw_devices, link) { - close(hidraw->fd); + xclose(&hidraw->fd); list_remove(&hidraw->link); free(hidraw->name); free(hidraw);