ASoC: Intel: avs: Replace snprintf() with scnprintf()
Subsystems (3)
PATCH v3 1/1 ASoC: Intel: avs: Replace snprintf() with scnprintf()
From: HariKrishna Sagala <[email protected]>
snprintf() as defined by the C99 standard,returns the number of characters that *would have been* written if enough space were available.Use scnprintf() that returns the actual number of characters written.
---
Thank you all for the valuable feedback and suggestions.
This patch updates usage of snprintf() with scnprintf(). As in accordance with the C99 standard, snprintf() returns the number of characters that would have been written if enough space were available.With scnprintf(),the return value reflects the actual number of characters written. Change log:
V3:
Dropped the Fixes, stable tag & updated the commit message. scnprintf doesn't return the negative values as per the contract. Hence removed the check of ret < 0 as it is unreachable.
https://www.kernel.org/doc/html/latest/core-api/kernel-api.html#c.scnprintf
V2:
https://lore.kernel.org/all/[email protected]/
V1:
https://lore.kernel.org/all/[email protected]/
sound/soc/intel/avs/debugfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
sound/soc/intel/avs/debugfs.c +3 -6
@@ -119,16 +119,13 @@ static ssize_t probe_points_read(struct file *file, char __user *to, size_t coun }for (i =0 ; i < num_desc; i++) { - ret =snprintf (buf + len,PAGE_SIZE - len, -"Id: %#010x Purpose: %d Node id: %#x\n" , - desc[i].id.value, desc[i].purpose, desc[i].node_id.val); -if (ret <0 ) - goto free_desc; + ret =scnprintf (buf + len,PAGE_SIZE - len, +"Id: %#010x Purpose: %d Node id: %#x\n" , + desc[i].id.value, desc[i].purpose, desc[i].node_id.val); len += ret; } ret =simple_read_from_buffer (to, count, ppos, buf, len); -free_desc:kfree (desc); exit:kfree (buf);
base-commit: 24172e0d79900908cf5ebf366600616d29c9b417
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 6 lines · On Thu, 13 Nov 2025 19:56:38 +0530, [email protected] wrote:
snprintf()as defined by the C99 standard,returns the number of characters that *would have been* written if enough space were available.Usescnprintf()that returns the actual number of characters written.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: Intel: avs: Replace snprintf() with scnprintf()
commit: df919994d323c7c86e32fa2745730136d58ada12
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark