* [PATCH net-next] net: usb: switch to two-argument strscpy
@ 2026-01-26 3:50 Ethan Nelson-Moore
2026-01-26 10:07 ` Andy Shevchenko
2026-01-28 1:52 ` Jakub Kicinski
0 siblings, 2 replies; 4+ messages in thread
From: Ethan Nelson-Moore @ 2026-01-26 3:50 UTC (permalink / raw)
To: netdev, linux-usb
Cc: Ethan Nelson-Moore, Andy Shevchenko, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Thangaraj Samynathan,
Rengarajan Sundararajan, UNGLinuxDriver, Petko Manolov,
Oliver Neukum, Nikita Zhandarovich, Krzysztof Hałasa,
Deepanshu Kartikey, Thomas Gleixner, Ingo Molnar, Foster Snowhill,
Gustavo A. R. Silva, Kees Cook, Eric Biggers
All instances of strscpy in the USB network drivers use the size of the
destination. If given only two arguments, strscpy will automatically
use the size of the destination. Make the code more concise by
switching to the two-argument form of strscpy.
Also add a blank line after a variable declaration in catc.c to adhere
to kernel code style, since the surrounding code is being touched.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
drivers/net/usb/aqc111.c | 2 +-
drivers/net/usb/asix_common.c | 4 ++--
drivers/net/usb/catc.c | 5 +++--
drivers/net/usb/ipheth.c | 2 +-
drivers/net/usb/lan78xx.c | 2 +-
drivers/net/usb/pegasus.c | 2 +-
drivers/net/usb/r8152.c | 9 ++++-----
drivers/net/usb/rtl8150.c | 4 ++--
drivers/net/usb/sierra_net.c | 4 ++--
drivers/net/usb/sr9800.c | 4 ++--
drivers/net/usb/usbnet.c | 13 ++++++-------
11 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index 9201ee10a13f..71394cf2f450 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -207,7 +207,7 @@ static void aqc111_get_drvinfo(struct net_device *net,
/* Inherit standard device info */
usbnet_get_drvinfo(net, info);
- strscpy(info->driver, DRIVER_NAME, sizeof(info->driver));
+ strscpy(info->driver, DRIVER_NAME);
snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u.%u",
aqc111_data->fw_ver.major,
aqc111_data->fw_ver.minor,
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 6ab3486072cb..48a09be6801e 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -735,8 +735,8 @@ void asix_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
{
/* Inherit standard device info */
usbnet_get_drvinfo(net, info);
- strscpy(info->driver, DRIVER_NAME, sizeof(info->driver));
- strscpy(info->version, DRIVER_VERSION, sizeof(info->version));
+ strscpy(info->driver, DRIVER_NAME);
+ strscpy(info->version, DRIVER_VERSION);
}
int asix_set_mac_address(struct net_device *net, void *p)
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index 6759388692f8..05a5bd632582 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -672,8 +672,9 @@ static void catc_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
struct catc *catc = netdev_priv(dev);
- strscpy(info->driver, driver_name, sizeof(info->driver));
- strscpy(info->version, DRIVER_VERSION, sizeof(info->version));
+
+ strscpy(info->driver, driver_name);
+ strscpy(info->version, DRIVER_VERSION);
usb_make_path(catc->usbdev, info->bus_info, sizeof(info->bus_info));
}
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
index a19789b57190..a2d45aff93b6 100644
--- a/drivers/net/usb/ipheth.c
+++ b/drivers/net/usb/ipheth.c
@@ -586,7 +586,7 @@ static int ipheth_probe(struct usb_interface *intf,
netdev->netdev_ops = &ipheth_netdev_ops;
netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;
- strscpy(netdev->name, "eth%d", sizeof(netdev->name));
+ strscpy(netdev->name, "eth%d");
dev = netdev_priv(netdev);
dev->udev = udev;
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 00397a807393..2f31ebf25732 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1811,7 +1811,7 @@ static void lan78xx_get_drvinfo(struct net_device *net,
{
struct lan78xx_net *dev = netdev_priv(net);
- strscpy(info->driver, DRIVER_NAME, sizeof(info->driver));
+ strscpy(info->driver, DRIVER_NAME);
usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
}
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index c514483134f0..dfcf42bdbf5f 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -896,7 +896,7 @@ static void pegasus_get_drvinfo(struct net_device *dev,
{
pegasus_t *pegasus = netdev_priv(dev);
- strscpy(info->driver, driver_name, sizeof(info->driver));
+ strscpy(info->driver, driver_name);
usb_make_path(pegasus->usb, info->bus_info, sizeof(info->bus_info));
}
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 880b59ed5422..ef13b7663890 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -5256,7 +5256,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp, bool power_cut)
rtl_fw->post_fw(tp);
rtl_reset_ocp_base(tp);
- strscpy(rtl_fw->version, fw_hdr->version, RTL_VER_SIZE);
+ strscpy(rtl_fw->version, fw_hdr->version);
dev_dbg(&tp->intf->dev, "load %s successfully\n", rtl_fw->version);
}
@@ -8755,12 +8755,11 @@ static void rtl8152_get_drvinfo(struct net_device *netdev,
{
struct r8152 *tp = netdev_priv(netdev);
- strscpy(info->driver, MODULENAME, sizeof(info->driver));
- strscpy(info->version, DRIVER_VERSION, sizeof(info->version));
+ strscpy(info->driver, MODULENAME);
+ strscpy(info->version, DRIVER_VERSION);
usb_make_path(tp->udev, info->bus_info, sizeof(info->bus_info));
if (!IS_ERR_OR_NULL(tp->rtl_fw.fw))
- strscpy(info->fw_version, tp->rtl_fw.version,
- sizeof(info->fw_version));
+ strscpy(info->fw_version, tp->rtl_fw.version);
}
static
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index e40b0669d9f4..04b16181d992 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -784,8 +784,8 @@ static void rtl8150_get_drvinfo(struct net_device *netdev, struct ethtool_drvinf
{
rtl8150_t *dev = netdev_priv(netdev);
- strscpy(info->driver, driver_name, sizeof(info->driver));
- strscpy(info->version, DRIVER_VERSION, sizeof(info->version));
+ strscpy(info->driver, driver_name);
+ strscpy(info->version, DRIVER_VERSION);
usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
}
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 36c73db44f77..d8f5d8ac697c 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -612,8 +612,8 @@ static void sierra_net_get_drvinfo(struct net_device *net,
{
/* Inherit standard device info */
usbnet_get_drvinfo(net, info);
- strscpy(info->driver, driver_name, sizeof(info->driver));
- strscpy(info->version, DRIVER_VERSION, sizeof(info->version));
+ strscpy(info->driver, driver_name);
+ strscpy(info->version, DRIVER_VERSION);
}
static u32 sierra_net_get_link(struct net_device *net)
diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index 57947a5590cc..84fe53d1a721 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -474,8 +474,8 @@ static void sr_get_drvinfo(struct net_device *net,
{
/* Inherit standard device info */
usbnet_get_drvinfo(net, info);
- strscpy(info->driver, DRIVER_NAME, sizeof(info->driver));
- strscpy(info->version, DRIVER_VERSION, sizeof(info->version));
+ strscpy(info->driver, DRIVER_NAME);
+ strscpy(info->version, DRIVER_VERSION);
}
static u32 sr_get_link(struct net_device *net)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 9280ef544bbb..c5ab449469c4 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1089,9 +1089,8 @@ void usbnet_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
{
struct usbnet *dev = netdev_priv(net);
- strscpy(info->driver, dev->driver_name, sizeof(info->driver));
- strscpy(info->fw_version, dev->driver_info->description,
- sizeof(info->fw_version));
+ strscpy(info->driver, dev->driver_name);
+ strscpy(info->fw_version, dev->driver_info->description);
usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
}
EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
@@ -1783,7 +1782,7 @@ usbnet_probe(struct usb_interface *udev, const struct usb_device_id *prod)
dev->interrupt_count = 0;
dev->net = net;
- strscpy(net->name, "usb%d", sizeof(net->name));
+ strscpy(net->name, "usb%d");
/* rx and tx sides can use different message sizes;
* bind() should set rx_urb_size in that case.
@@ -1809,13 +1808,13 @@ usbnet_probe(struct usb_interface *udev, const struct usb_device_id *prod)
*/
if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
!usbnet_needs_usb_name_format(dev, net))
- strscpy(net->name, "eth%d", sizeof(net->name));
+ strscpy(net->name, "eth%d");
/* WLAN devices should always be named "wlan%d" */
if ((dev->driver_info->flags & FLAG_WLAN) != 0)
- strscpy(net->name, "wlan%d", sizeof(net->name));
+ strscpy(net->name, "wlan%d");
/* WWAN devices should always be named "wwan%d" */
if ((dev->driver_info->flags & FLAG_WWAN) != 0)
- strscpy(net->name, "wwan%d", sizeof(net->name));
+ strscpy(net->name, "wwan%d");
/* devices that cannot do ARP */
if ((dev->driver_info->flags & FLAG_NOARP) != 0)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net-next] net: usb: switch to two-argument strscpy
2026-01-26 3:50 [PATCH net-next] net: usb: switch to two-argument strscpy Ethan Nelson-Moore
@ 2026-01-26 10:07 ` Andy Shevchenko
2026-01-27 7:27 ` Andy Shevchenko
2026-01-28 1:52 ` Jakub Kicinski
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-01-26 10:07 UTC (permalink / raw)
To: Ethan Nelson-Moore
Cc: netdev, linux-usb, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Thangaraj Samynathan,
Rengarajan Sundararajan, UNGLinuxDriver, Petko Manolov,
Oliver Neukum, Nikita Zhandarovich, Krzysztof Hałasa,
Deepanshu Kartikey, Thomas Gleixner, Ingo Molnar, Foster Snowhill,
Gustavo A. R. Silva, Kees Cook, Eric Biggers
On Sun, Jan 25, 2026 at 07:50:15PM -0800, Ethan Nelson-Moore wrote:
> All instances of strscpy in the USB network drivers use the size of the
> destination. If given only two arguments, strscpy will automatically
> use the size of the destination. Make the code more concise by
> switching to the two-argument form of strscpy.
>
> Also add a blank line after a variable declaration in catc.c to adhere
> to kernel code style, since the surrounding code is being touched.
It should go after your patch that drops some of the strscpy():s.
Hence make a v3 as a series of two patches.
Code wise this LGTM, thanks for doing this.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: usb: switch to two-argument strscpy
2026-01-26 10:07 ` Andy Shevchenko
@ 2026-01-27 7:27 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-01-27 7:27 UTC (permalink / raw)
To: Ethan Nelson-Moore
Cc: netdev, linux-usb, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Thangaraj Samynathan,
Rengarajan Sundararajan, UNGLinuxDriver, Petko Manolov,
Oliver Neukum, Nikita Zhandarovich, Krzysztof Hałasa,
Deepanshu Kartikey, Thomas Gleixner, Ingo Molnar, Foster Snowhill,
Gustavo A. R. Silva, Kees Cook, Eric Biggers
On Mon, Jan 26, 2026 at 12:07:57PM +0200, Andy Shevchenko wrote:
> On Sun, Jan 25, 2026 at 07:50:15PM -0800, Ethan Nelson-Moore wrote:
> > All instances of strscpy in the USB network drivers use the size of the
> > destination. If given only two arguments, strscpy will automatically
> > use the size of the destination. Make the code more concise by
> > switching to the two-argument form of strscpy.
> >
> > Also add a blank line after a variable declaration in catc.c to adhere
> > to kernel code style, since the surrounding code is being touched.
>
> It should go after your patch that drops some of the strscpy():s.
> Hence make a v3 as a series of two patches.
FWIW, your v3 missed this patch... What's your plan with it?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: usb: switch to two-argument strscpy
2026-01-26 3:50 [PATCH net-next] net: usb: switch to two-argument strscpy Ethan Nelson-Moore
2026-01-26 10:07 ` Andy Shevchenko
@ 2026-01-28 1:52 ` Jakub Kicinski
1 sibling, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2026-01-28 1:52 UTC (permalink / raw)
To: Ethan Nelson-Moore
Cc: netdev, linux-usb, Andy Shevchenko, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Thangaraj Samynathan,
Rengarajan Sundararajan, UNGLinuxDriver, Petko Manolov,
Oliver Neukum, Nikita Zhandarovich, Krzysztof Hałasa,
Deepanshu Kartikey, Thomas Gleixner, Ingo Molnar, Foster Snowhill,
Gustavo A. R. Silva, Kees Cook, Eric Biggers
On Sun, 25 Jan 2026 19:50:15 -0800 Ethan Nelson-Moore wrote:
> All instances of strscpy in the USB network drivers use the size of the
> destination. If given only two arguments, strscpy will automatically
> use the size of the destination. Make the code more concise by
> switching to the two-argument form of strscpy.
>
> Also add a blank line after a variable declaration in catc.c to adhere
> to kernel code style, since the surrounding code is being touched.
Let's not waste our time replacing all 3-arg strscpy()s with 2-arg right
after we wasted our time replacing strxcpy() with strscpy(). Who cares.
--
pw-bot: reject
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-28 1:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-26 3:50 [PATCH net-next] net: usb: switch to two-argument strscpy Ethan Nelson-Moore
2026-01-26 10:07 ` Andy Shevchenko
2026-01-27 7:27 ` Andy Shevchenko
2026-01-28 1:52 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox