[PATCH] Input: adi - use scnprintf() for the device name

From: Aibing Chen

Date: Thu Nov 26 2026 - 00:32:43 EST


adi_init_input() composes the device name as "Logitech %s [%s]" from the
model string in buf[] and the controller name in adi->cname, into a 64
byte array. buf can hold up to 63 characters and cname up to 15, so the
composed name can reach 90 bytes and does not fit. The name is
informational and truncating it is acceptable, but the call site does not
say so.

Building with W=1, where -Wformat-truncation is enabled, the file does not
build today; COMPILE_TEST configurations additionally turn the warning
into an error through CONFIG_WERROR:

drivers/input/joystick/adi.c:395:60: error: '%s' directive output may be
truncated writing up to 63 bytes into a region of size 55
[-Werror=format-truncation=]

Use scnprintf(), the helper that expresses a bounded, truncation tolerant
write, so that the file builds warning free and the intent is visible at
the call site.

No functional change.

Signed-off-by: Aibing Chen <chenaibing@xxxxxxxxxxxxxxxxxxxx>
---
drivers/input/joystick/adi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index e07b71978..0b60c8067 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -392,7 +392,7 @@ static int adi_init_input(struct adi *adi, struct adi_port *port, int half)
t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX;

snprintf(buf, ADI_MAX_PHYS_LENGTH, adi_names[t], adi->id);
- snprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s [%s]", buf, adi->cname);
+ scnprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s [%s]", buf, adi->cname);
snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half);

adi->abs = adi_abs[t];