]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: Space: Replace memset(0) + strscpy() with strscpy_pad()
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 14 Aug 2025 18:05:14 +0000 (20:05 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 Aug 2025 19:37:50 +0000 (12:37 -0700)
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>
drivers/net/Space.c

index dc50797a2ed05e6a73ab6f0d3f83f62446d8c642..c01e2c2f7d6c7f619960cdaba02257db250d609e 100644 (file)
@@ -67,8 +67,7 @@ static int netdev_boot_setup_add(char *name, struct ifmap *map)
        s = dev_boot_setup;
        for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
                if (s[i].name[0] == '\0' || s[i].name[0] == ' ') {
-                       memset(s[i].name, 0, sizeof(s[i].name));
-                       strscpy(s[i].name, name, IFNAMSIZ);
+                       strscpy_pad(s[i].name, name);
                        memcpy(&s[i].map, map, sizeof(s[i].map));
                        break;
                }