The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Aibing Chen <chenaibing@cmss.chinamobile.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: cobra - use scnprintf() for the device physical path
Date: Wed, 25 Nov 2026 21:48:42 -0800	[thread overview]
Message-ID: <awfIN2YNK4aY0l9l@google.com> (raw)
In-Reply-To: <20261126035206.1062-1-chenaibing@cmss.chinamobile.com>

On Thu, Nov 26, 2026 at 11:52:06AM +0800, Aibing Chen wrote:
> 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>

Applied, thank you.

-- 
Dmitry

      reply	other threads:[~2026-11-26  5:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  3:52 [PATCH] Input: cobra - use scnprintf() for the device physical path Aibing Chen
2026-11-26  5:48 ` Dmitry Torokhov [this message]

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=awfIN2YNK4aY0l9l@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=chenaibing@cmss.chinamobile.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