From: Aibing Chen <chenaibing@cmss.chinamobile.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] Input: sidewinder: use scnprintf() for the comment and physical path
Date: Fri, 27 Nov 2026 11:49:04 +0800 [thread overview]
Message-ID: <20261127034904.288-2-chenaibing@cmss.chinamobile.com> (raw)
In-Reply-To: <20261127034904.288-1-chenaibing@cmss.chinamobile.com>
sw_3dp_id() appends the PnP information to the caller's comment buffer
with snprintf(), and sw_connect() composes the physical path of each
device as "%s/input%d" from gameport->phys, which is a 32 byte string.
Both strings can be truncated, which is acceptable for informational
text, but with W=1 the file does not build:
drivers/input/joystick/sidewinder.c:538:58: error: '%s' directive
output may be truncated writing up to 8 bytes into a region of size
between 5 and 21 [-Werror=format-truncation=]
drivers/input/joystick/sidewinder.c:727:29: error: '/input' directive
output may be truncated writing 6 bytes into a region of size between
1 and 32 [-Werror=format-truncation=]
Use scnprintf() so that the writes are explicitly bounded and the file
builds warning free.
No functional change.
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
drivers/input/joystick/sidewinder.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 7f37d18c8..f6f76108d 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -535,7 +535,7 @@ static void sw_3dp_id(unsigned char *buf, char *comment, size_t size)
pnp[7] = rev[8] = 0;
- snprintf(comment, size, " [PnP %d.%02d id %s rev %s]",
+ scnprintf(comment, size, " [PnP %d.%02d id %s rev %s]",
(int) ((sw_get_bits(buf, 8, 6, 1) << 6) | /* Two 6-bit values */
sw_get_bits(buf, 16, 6, 1)) / 100,
(int) ((sw_get_bits(buf, 8, 6, 1) << 6) |
@@ -723,7 +723,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
snprintf(sw->name, sizeof(sw->name),
"Microsoft SideWinder %s", sw_name[sw->type]);
- snprintf(sw->phys[i], sizeof(sw->phys[i]),
+ scnprintf(sw->phys[i], sizeof(sw->phys[i]),
"%s/input%d", gameport->phys, i);
sw->dev[i] = input_dev = input_allocate_device();
next prev parent reply other threads:[~2026-11-27 3:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 3:49 [PATCH 1/2] Input: joystick: use scnprintf() for the device physical paths Aibing Chen
2026-11-27 3:49 ` Aibing Chen [this message]
2026-11-27 4:05 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127034904.288-2-chenaibing@cmss.chinamobile.com \
--to=chenaibing@cmss.chinamobile.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox