MIPS: move from strlcpy with unused retval to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 18 Aug 2022 20:59:43 +0000 (22:59 +0200)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Mon, 12 Sep 2022 13:34:04 +0000 (15:34 +0200)
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/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/kernel/prom.c
arch/mips/kernel/relocate.c
arch/mips/pic32/pic32mzda/init.c

index 7db6ff9aed7dff9cef8c56544be894b71c307b31..f88ce78e13e3a2de9f51d33531398c96d807d7f2 100644 (file)
@@ -26,7 +26,7 @@ __init void mips_set_machine_name(const char *name)
        if (name == NULL)
                return;
 
-       strlcpy(mips_machine_name, name, sizeof(mips_machine_name));
+       strscpy(mips_machine_name, name, sizeof(mips_machine_name));
        pr_info("MIPS: machine is %s\n", mips_get_machine_name());
 }
 
@@ -52,9 +52,9 @@ int __init __dt_register_buses(const char *bus0, const char *bus1)
        if (!of_have_populated_dt())
                panic("device tree not present");
 
-       strlcpy(of_ids[0].compatible, bus0, sizeof(of_ids[0].compatible));
+       strscpy(of_ids[0].compatible, bus0, sizeof(of_ids[0].compatible));
        if (bus1) {
-               strlcpy(of_ids[1].compatible, bus1,
+               strscpy(of_ids[1].compatible, bus1,
                        sizeof(of_ids[1].compatible));
        }
 
index 56b51de2dc51b3e00e1e34f2fe4df6d90c04e146..58fc8d089402bd86649596ef422aaee7c7814fcb 100644 (file)
@@ -340,7 +340,7 @@ void *__init relocate_kernel(void)
        early_init_dt_scan(fdt);
        if (boot_command_line[0]) {
                /* Boot command line was passed in device tree */
-               strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
+               strscpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
        }
 #endif /* CONFIG_USE_OF */
 
index d9c8c4e46aff99e1b86ba734a9a57f3522bec43d..08c46cf122d73576c9998c861ebe1fcd3f4076f7 100644 (file)
@@ -44,7 +44,7 @@ void __init plat_mem_setup(void)
        pr_info(" builtin_cmdline  : %s\n", CONFIG_CMDLINE);
 #endif
        if (dtb != __dtb_start)
-               strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
+               strscpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
 
 #ifdef CONFIG_EARLY_PRINTK
        fw_init_early_console(-1);