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

ASoC: intel: avs: refactor strncpy usage in topology

`strncpy` is deprecated for use on NUL-terminated destination strings
[1].

A suitable replacement is `strscpy` [2].

There are some hopes that someday the `strncpy` api could be ripped out
due to the vast number of suitable replacements (strscpy, strscpy_pad,
strtomem, strtomem_pad, strlcpy) [1].

[1]: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
[2]: manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html

Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20230725-sound-soc-intel-avs-remove-deprecated-strncpy-v1-1-6357a1f8e9cf@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

justinstitt@google.com and committed by
Mark Brown
f6500ec1 5bdeb6f5

+3 -3
+3 -3
sound/soc/intel/avs/topology.c
··· 1388 1388 port = __ffs(mach->mach_params.i2s_link_mask); 1389 1389 1390 1390 snprintf(buf, len, route->source, port); 1391 - strncpy((char *)route->source, buf, len); 1391 + strscpy((char *)route->source, buf, len); 1392 1392 snprintf(buf, len, route->sink, port); 1393 - strncpy((char *)route->sink, buf, len); 1393 + strscpy((char *)route->sink, buf, len); 1394 1394 if (route->control) { 1395 1395 snprintf(buf, len, route->control, port); 1396 - strncpy((char *)route->control, buf, len); 1396 + strscpy((char *)route->control, buf, len); 1397 1397 } 1398 1398 } 1399 1399