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

bridge: 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>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://lore.kernel.org/r/20220818210212.8347-1-wsa+renesas@sang-engineering.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Wolfram Sang and committed by
Jakub Kicinski
993e1634 6164b5e3

+7 -7
+4 -4
net/bridge/br_device.c
··· 251 251 252 252 static void br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info) 253 253 { 254 - strlcpy(info->driver, "bridge", sizeof(info->driver)); 255 - strlcpy(info->version, BR_VERSION, sizeof(info->version)); 256 - strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); 257 - strlcpy(info->bus_info, "N/A", sizeof(info->bus_info)); 254 + strscpy(info->driver, "bridge", sizeof(info->driver)); 255 + strscpy(info->version, BR_VERSION, sizeof(info->version)); 256 + strscpy(info->fw_version, "N/A", sizeof(info->fw_version)); 257 + strscpy(info->bus_info, "N/A", sizeof(info->bus_info)); 258 258 } 259 259 260 260 static int br_get_link_ksettings(struct net_device *dev,
+2 -2
net/bridge/br_sysfs_if.c
··· 384 384 return err; 385 385 } 386 386 387 - strlcpy(p->sysfs_name, p->dev->name, IFNAMSIZ); 387 + strscpy(p->sysfs_name, p->dev->name, IFNAMSIZ); 388 388 return sysfs_create_link(br->ifobj, &p->kobj, p->sysfs_name); 389 389 } 390 390 ··· 406 406 netdev_notice(br->dev, "unable to rename link %s to %s", 407 407 p->sysfs_name, p->dev->name); 408 408 else 409 - strlcpy(p->sysfs_name, p->dev->name, IFNAMSIZ); 409 + strscpy(p->sysfs_name, p->dev->name, IFNAMSIZ); 410 410 411 411 return err; 412 412 }
+1 -1
net/bridge/netfilter/ebtables.c
··· 1446 1446 /* ebtables expects 31 bytes long names but xt_match names are 29 bytes 1447 1447 * long. Copy 29 bytes and fill remaining bytes with zeroes. 1448 1448 */ 1449 - strlcpy(name, _name, sizeof(name)); 1449 + strscpy(name, _name, sizeof(name)); 1450 1450 if (copy_to_user(um, name, EBT_EXTENSION_MAXNAMELEN) || 1451 1451 put_user(revision, (u8 __user *)(um + EBT_EXTENSION_MAXNAMELEN)) || 1452 1452 put_user(datasize, (int __user *)(um + EBT_EXTENSION_MAXNAMELEN + 1)) ||