From c5883013b080ab63e0530ceba04f249b0d0d11e6 Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 4 Mar 2024 20:21:52 +0100 Subject: [PATCH] Return the correct name during a device scan In scan_device(), the returned device name was computed wrongly. It is opened a device, then if it was found as touchscreen it is computed the name again in a different way. It is better (and simpler) to return a strdup() of the last successfully opened device. Signed-off-by: Goffredo Baroncelli --- src/ts_setup.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/ts_setup.c b/src/ts_setup.c index e11db0e3..c6981402 100644 --- a/src/ts_setup.c +++ b/src/ts_setup.c @@ -85,15 +85,7 @@ static char *scan_devices(void) continue; } else { close(fd); - filename = malloc(strlen(DEV_INPUT_EVENT) + - strlen(EVENT_DEV_NAME) + - 12); - if (!filename) - break; - - sprintf(filename, "%s/%s%d", - DEV_INPUT_EVENT, EVENT_DEV_NAME, - i); + filename = strdup(fname); break; } }