* [PATCH] Input: adi - use scnprintf() for the device name
@ 2026-11-26 5:32 Aibing Chen
2026-11-26 5:42 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Aibing Chen @ 2026-11-26 5:32 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel
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@cmss.chinamobile.com>
---
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];
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: adi - use scnprintf() for the device name
2026-11-26 5:32 [PATCH] Input: adi - use scnprintf() for the device name Aibing Chen
@ 2026-11-26 5:42 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-11-26 5:42 UTC (permalink / raw)
To: Aibing Chen; +Cc: linux-input, linux-kernel
On Thu, Nov 26, 2026 at 01:32:34PM +0800, Aibing Chen wrote:
> 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@cmss.chinamobile.com>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 5:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 5:32 [PATCH] Input: adi - use scnprintf() for the device name Aibing Chen
2026-11-26 5:42 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox