Skip to content

Commit

Permalink
ASoC: intel: avs: refactor strncpy usage in topology
Browse files Browse the repository at this point in the history
`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: KSPP#90
Signed-off-by: Justin Stitt <[email protected]>
Link: https://lore.kernel.org/r/20230725-sound-soc-intel-avs-remove-deprecated-strncpy-v1-1-6357a1f8e9cf@google.com
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
JustinStitt authored and broonie committed Jul 26, 2023
1 parent 5bdeb6f commit f6500ec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sound/soc/intel/avs/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,12 +1388,12 @@ static int avs_route_load(struct snd_soc_component *comp, int index,
port = __ffs(mach->mach_params.i2s_link_mask);

snprintf(buf, len, route->source, port);
strncpy((char *)route->source, buf, len);
strscpy((char *)route->source, buf, len);
snprintf(buf, len, route->sink, port);
strncpy((char *)route->sink, buf, len);
strscpy((char *)route->sink, buf, len);
if (route->control) {
snprintf(buf, len, route->control, port);
strncpy((char *)route->control, buf, len);
strscpy((char *)route->control, buf, len);
}
}

Expand Down

0 comments on commit f6500ec

Please sign in to comment.