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

init: move from strlcpy with unused retval to strscpy

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Link: https://lkml.kernel.org/r/20220818210200.8203-1-wsa+renesas@sang-engineering.com
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Wolfram Sang and committed by
Andrew Morton
a1d3a6d9 512cb7e4

+4 -4
+2 -2
init/do_mounts.c
··· 296 296 297 297 static int __init root_dev_setup(char *line) 298 298 { 299 - strlcpy(saved_root_name, line, sizeof(saved_root_name)); 299 + strscpy(saved_root_name, line, sizeof(saved_root_name)); 300 300 return 1; 301 301 } 302 302 ··· 343 343 int count = 1; 344 344 char *p = page; 345 345 346 - strlcpy(p, root_fs_names, size); 346 + strscpy(p, root_fs_names, size); 347 347 while (*p++) { 348 348 if (p[-1] == ',') { 349 349 p[-1] = '\0';
+2 -2
init/main.c
··· 422 422 if (!data) 423 423 data = xbc_get_embedded_bootconfig(&size); 424 424 425 - strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); 425 + strscpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); 426 426 err = parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL, 427 427 bootconfig_params); 428 428 ··· 762 762 return; 763 763 764 764 /* All fall through to do_early_param. */ 765 - strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); 765 + strscpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); 766 766 parse_early_options(tmp_cmdline); 767 767 done = 1; 768 768 }