From b87532dfb582d08b0db0efcdbc59357f5e845877 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 16 Apr 2026 10:25:55 +1000 Subject: [PATCH] touchpad: replace sprintf strv_join in the touch state debugging This is purely to make Claude happy, the function is ifdef'd out and to actually hit the limit we'd need more than ~25 slots active. Anyway, the strv helpers make for much nicer code anyway. Co-Authored-by: Claude Code Part-of: --- src/evdev-mt-touchpad.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 4b9e1dde..0c1c3803 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1837,23 +1837,25 @@ tp_handle_state(struct tp_dispatch *tp, usec_t time) _unused_ static inline void tp_debug_touch_state(struct tp_dispatch *tp, struct evdev_device *device) { - char buf[1024] = { 0 }; + _autostrvfree_ char **strv = NULL; struct tp_touch *t; size_t i = 0; tp_for_each_touch(tp, t) { if (i >= tp->nfingers_down) break; - sprintf(&buf[strlen(buf)], - "slot %zd: %04d/%04d p%03d %s |", - i++, - t->point.x, - t->point.y, - t->pressure, - tp_touch_active(tp, t) ? "" : "inactive"); + strv = strv_append_printf(strv, + "slot %zd: %04d/%04d p%03d %s", + i++, + t->point.x, + t->point.y, + t->pressure, + tp_touch_active(tp, t) ? "" : "inactive"); } - if (buf[0] != '\0') + if (strv) { + _autofree_ char *buf = strv_join(strv, " | "); evdev_log_debug(device, "touch state: %s\n", buf); + } } static void