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

net: Space: Replace memset(0) + strscpy() with strscpy_pad()

Replace memset(0) followed by strscpy() with strscpy_pad() to improve
netdev_boot_setup_add(). This avoids zeroing the memory before copying
the string and ensures the destination buffer is only written to once,
simplifying the code and improving efficiency.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250814180514.251000-2-thorsten.blum@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Thorsten Blum and committed by
Jakub Kicinski
81595729 e63b162e

+1 -2
+1 -2
drivers/net/Space.c
··· 67 67 s = dev_boot_setup; 68 68 for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) { 69 69 if (s[i].name[0] == '\0' || s[i].name[0] == ' ') { 70 - memset(s[i].name, 0, sizeof(s[i].name)); 71 - strscpy(s[i].name, name, IFNAMSIZ); 70 + strscpy_pad(s[i].name, name); 72 71 memcpy(&s[i].map, map, sizeof(s[i].map)); 73 72 break; 74 73 }