Skip to content

Commit 8159572

Browse files
tobluxkuba-moo
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e63b162 commit 8159572

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/net/Space.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ static int netdev_boot_setup_add(char *name, struct ifmap *map)
6767
s = dev_boot_setup;
6868
for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
6969
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);
7271
memcpy(&s[i].map, map, sizeof(s[i].map));
7372
break;
7473
}

0 commit comments

Comments
 (0)