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

mtd: 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/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220818210033.7084-1-wsa+renesas@sang-engineering.com

authored by

Wolfram Sang and committed by
Miquel Raynal
80b7e928 bf3e6b8f

+3 -3
+1 -1
drivers/mtd/devices/block2mtd.c
··· 461 461 the device (even kmalloc() fails). Deter that work to 462 462 block2mtd_setup2(). */ 463 463 464 - strlcpy(block2mtd_paramline, val, sizeof(block2mtd_paramline)); 464 + strscpy(block2mtd_paramline, val, sizeof(block2mtd_paramline)); 465 465 466 466 return 0; 467 467 #endif
+2 -2
drivers/mtd/parsers/cmdlinepart.c
··· 193 193 parts[this_part].mask_flags = mask_flags; 194 194 parts[this_part].add_flags = add_flags; 195 195 if (name) 196 - strlcpy(extra_mem, name, name_len + 1); 196 + strscpy(extra_mem, name, name_len + 1); 197 197 else 198 198 sprintf(extra_mem, "Partition_%03d", this_part); 199 199 parts[this_part].name = extra_mem; ··· 298 298 this_mtd->parts = parts; 299 299 this_mtd->num_parts = num_parts; 300 300 this_mtd->mtd_id = (char*)(this_mtd + 1); 301 - strlcpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1); 301 + strscpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1); 302 302 303 303 /* link into chain */ 304 304 this_mtd->next = partitions;