Linux Sound subsystem development
 help / color / mirror / Atom feed
From: hariconscious@gmail.com
To: lgirdwood@gmail.com, peter.ujfalusi@linux.intel.com,
	yung-chuan.liao@linux.intel.com,
	ranjani.sridharan@linux.intel.com, daniel.baluta@nxp.com,
	kai.vehmanen@linux.intel.com, pierre-louis.bossart@linux.dev,
	broonie@kernel.org
Cc: perex@perex.cz, tiwai@suse.com, khalid@kernel.org,
	shuah@kernel.org, david.hunter.linux@gmail.com,
	sound-open-firmware@alsa-project.org,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	HariKrishna Sagala <hariconscious@gmail.com>
Subject: [PATCH] ASoC: SOF: sof-client-probes: Replace snprintf() with scnprintf()
Date: Tue, 11 Nov 2025 10:59:21 +0530	[thread overview]
Message-ID: <20251111052920.56459-2-hariconscious@gmail.com> (raw)

From: HariKrishna Sagala <hariconscious@gmail.com>

As per the C99 standard snprintf() returns the length of the data
that *would have been* written if there were enough space for it.
It's generally considered safer to use the scnprintf() variant.

Link: https://github.com/KSPP/linux/issues/105
Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
---
This patch replaces snprintf() varaint with scnprintf() in
scenario to know the actual length of the data rather than *would
have been* written data of snprintf().
No functional changes intended.
Reference Links:
https://lwn.net/Articles/69419/
https://www.kernel.org/doc/html/latest/core-api/kernel-api.html#c.snprintf

Note:
*Compile & boot* tested.(CONFIG_SND_SOC_SOF_IPC4=y)

Thank you.

 sound/soc/sof/sof-client-probes-ipc4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/sof/sof-client-probes-ipc4.c b/sound/soc/sof/sof-client-probes-ipc4.c
index 758a56d271d7..d3fa37106b64 100644
--- a/sound/soc/sof/sof-client-probes-ipc4.c
+++ b/sound/soc/sof/sof-client-probes-ipc4.c
@@ -289,7 +289,7 @@ static int ipc4_probes_point_print(struct sof_client_dev *cdev, char *buf, size_
 			__func__, SOF_IPC4_MOD_ID_GET(desc->buffer_id),
 			SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
 
-	ret = snprintf(buf, size, "%#x,%#x,%#x\t%s %s buf idx %lu %s\n",
+	ret = scnprintf(buf, size, "%#x,%#x,%#x\t%s %s buf idx %lu %s\n",
 		       desc->buffer_id, desc->purpose, desc->stream_tag,
 		       swidget ? swidget->widget->name : "<unknown>",
 		       sof_probe_ipc4_type_string(SOF_IPC4_PROBE_TYPE_GET(desc->buffer_id)),

base-commit: 4427259cc7f7571a157fbc9b5011e1ef6fe0a4a8
-- 
2.43.0


             reply	other threads:[~2025-11-11  5:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-11  5:29 hariconscious [this message]
2025-11-19  2:09 ` [PATCH] ASoC: SOF: sof-client-probes: Replace snprintf() with scnprintf() Mark Brown

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=20251111052920.56459-2-hariconscious@gmail.com \
    --to=hariconscious@gmail.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=david.hunter.linux@gmail.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=khalid@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=shuah@kernel.org \
    --cc=sound-open-firmware@alsa-project.org \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.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