Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: Intel: avs: Replace snprintf() with scnprintf()

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.

Link: https://github.com/KSPP/linux/issues/105
Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
Link: https://patch.msgid.link/20251113142637.259737-2-hariconscious@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

HariKrishna Sagala and committed by
Mark Brown
df919994 3efee736

+3 -6
+3 -6
sound/soc/intel/avs/debugfs.c
··· 119 119 } 120 120 121 121 for (i = 0; i < num_desc; i++) { 122 - ret = snprintf(buf + len, PAGE_SIZE - len, 123 - "Id: %#010x Purpose: %d Node id: %#x\n", 124 - desc[i].id.value, desc[i].purpose, desc[i].node_id.val); 125 - if (ret < 0) 126 - goto free_desc; 122 + ret = scnprintf(buf + len, PAGE_SIZE - len, 123 + "Id: %#010x Purpose: %d Node id: %#x\n", 124 + desc[i].id.value, desc[i].purpose, desc[i].node_id.val); 127 125 len += ret; 128 126 } 129 127 130 128 ret = simple_read_from_buffer(to, count, ppos, buf, len); 131 - free_desc: 132 129 kfree(desc); 133 130 exit: 134 131 kfree(buf);