From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Sun Jian <sun.jian.kdev@gmail.com>
Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>,
Johan Hovold <johan@kernel.org>,
Mark Greer <mgreer@animalcreek.com>,
Alex Elder <elder@kernel.org>,
David Laight <david.laight.linux@gmail.com>,
greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: greybus: audio: avoid snprintf truncation warnings
Date: Mon, 29 Dec 2025 17:52:34 +0100 [thread overview]
Message-ID: <2025122922-wrath-elevating-bd85@gregkh> (raw)
In-Reply-To: <20251229161346.188805-1-sun.jian.kdev@gmail.com>
On Tue, Dec 30, 2025 at 12:13:46AM +0800, Sun Jian wrote:
> W=1 reports possible truncation when formatting widget/control names
> with snprintf() and a %s argument. Use a small helper and hide the %s
> pointer from the compiler's truncation analysis via OPTIMIZER_HIDE_VAR(),
> while keeping the existing snprintf() formatting.
>
> No functional change intended.
>
> Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
> ---
> drivers/staging/greybus/audio_topology.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
> index 76146f91cddc..4293ab899390 100644
> --- a/drivers/staging/greybus/audio_topology.c
> +++ b/drivers/staging/greybus/audio_topology.c
> @@ -1087,7 +1087,8 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
>
> /* Prefix dev_id to widget control_name */
> strscpy(temp_name, w->name, sizeof(temp_name));
> - snprintf(w->name, sizeof(w->name), "GB %d %s", module->dev_id, temp_name);
> + scnprintf(w->name, sizeof(w->name), "GB %d ", module->dev_id);
> + strlcat(w->name, temp_name, sizeof(w->name));
>
> switch (w->type) {
> case snd_soc_dapm_spk:
> @@ -1169,8 +1170,8 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
> control->id = curr->id;
> /* Prefix dev_id to widget_name */
> strscpy(temp_name, curr->name, sizeof(temp_name));
> - snprintf(curr->name, sizeof(curr->name), "GB %d %s", module->dev_id,
> - temp_name);
> + scnprintf(curr->name, sizeof(curr->name), "GB %d ", module->dev_id);
> + strlcat(curr->name, temp_name, sizeof(curr->name));
> control->name = curr->name;
> if (curr->info.type == GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED) {
> struct gb_audio_enumerated *gbenum =
> --
> 2.43.0
>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/process/submitting-patches.rst for what
needs to be done here to properly describe this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
next prev parent reply other threads:[~2025-12-29 16:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-29 11:26 [PATCH] staging: greybus: audio: avoid snprintf truncation warnings Sun Jian
2025-12-29 14:17 ` David Laight
2025-12-29 16:13 ` [PATCH v2] " Sun Jian
2025-12-29 16:52 ` Greg Kroah-Hartman [this message]
2025-12-30 1:29 ` [PATCH v3] " Sun Jian
2025-12-30 7:40 ` Greg Kroah-Hartman
2025-12-30 22:20 ` David Laight
2026-01-05 11:55 ` Dan Carpenter
2026-01-05 15:37 ` sun jian
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=2025122922-wrath-elevating-bd85@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=david.laight.linux@gmail.com \
--cc=elder@kernel.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mgreer@animalcreek.com \
--cc=sun.jian.kdev@gmail.com \
--cc=vaibhav.sr@gmail.com \
/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