[Intel-wired-lan] [PATCH] net: move from strlcpy with unused retval to strscpy
Geoff Levand
geoff at infradead.org
Fri Aug 19 15:26:57 UTC 2022
Hi Wolfram,
On 8/18/22 14:00, Wolfram Sang wrote:
> 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 at sang-engineering.com>
...
> diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> index 3dbfb1b20649..6e838e8f79d0 100644
> --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> @@ -1187,8 +1187,8 @@ int gelic_net_open(struct net_device *netdev)
> void gelic_net_get_drvinfo(struct net_device *netdev,
> struct ethtool_drvinfo *info)
> {
> - strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
> - strlcpy(info->version, DRV_VERSION, sizeof(info->version));
> + strscpy(info->driver, DRV_NAME, sizeof(info->driver));
> + strscpy(info->version, DRV_VERSION, sizeof(info->version));
> }
> ps3_gelic_net
> static int gelic_ether_get_link_ksettings(struct net_device *netdev,
> diff --git a/drivers/net/ethernet/toshiba/spider_net_ethtool.c b/drivers/net/ethernet/toshiba/spider_net_ethtool.c
> index 93110dba0bfa..fef9fd127b5e 100644
> --- a/drivers/net/ethernet/toshiba/spider_net_ethtool.c
> +++ b/drivers/net/ethernet/toshiba/spider_net_ethtool.c
> @@ -63,12 +63,12 @@ spider_net_ethtool_get_drvinfo(struct net_device *netdev,
> card = netdev_priv(netdev);
>
> /* clear and fill out info */
> - strlcpy(drvinfo->driver, spider_net_driver_name,
> + strscpy(drvinfo->driver, spider_net_driver_name,
> sizeof(drvinfo->driver));
> - strlcpy(drvinfo->version, VERSION, sizeof(drvinfo->version));
> - strlcpy(drvinfo->fw_version, "no information",
> + strscpy(drvinfo->version, VERSION, sizeof(drvinfo->version));
> + strscpy(drvinfo->fw_version, "no information",
> sizeof(drvinfo->fw_version));
> - strlcpy(drvinfo->bus_info, pci_name(card->pdev),
> + strscpy(drvinfo->bus_info, pci_name(card->pdev),
> sizeof(drvinfo->bus_info));
> }
Seems OK for both ps3_gelic_net and spider_net_ethtool.
Acked-by: Geoff Levand <geoff at infradead.org>
More information about the Intel-wired-lan
mailing list