Re: [PATCH] Input: adi - use scnprintf() for the device name
From: Dmitry Torokhov
Date: Thu Nov 26 2026 - 00:42:33 EST
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@xxxxxxxxxxxxxxxxxxxx>
Applied, thank you.
--
Dmitry