Input: cobra - use scnprintf() for the device physical path
cobra_connect() composes the physical path of each port as "%s/input%d"
from gameport->phys into a 32 byte array. gameport->phys can hold up to
31 characters, so the composed string reaches 39 bytes and does not fit.
The path is informational only 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 at all today; COMPILE_TEST configurations additionally turn the
warning into an error through CONFIG_WERROR:
drivers/input/joystick/cobra.c:184:29: error: '/input' directive output
may be truncated writing 6 bytes into a region of size between 1 and
32 [-Werror=format-truncation=]
note: 'snprintf' output between 8 and 39 bytes into a destination of
size 32
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>
Link: https://patch.msgid.link/20261126035206.1062-1-chenaibing@cmss.chinamobile.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 file changed