Use a safer function strscpy() instead of strcpy() for copying to
arrays.
Only idiomatic code replacement, and no functional changes.
Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
drivers/usb/usbip/vhci_sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index bfc10f665e52..5bc8c47788d4 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -463,7 +463,7 @@ static void set_status_attr(int id)
status = status_attrs + id;
if (id == 0)
- strcpy(status->name, "status");
+ strscpy(status->name, "status");
else
snprintf(status->name, MAX_STATUS_NAME+1, "status.%d", id);
status->attr.attr.name = status->name;
--
2.34.1
On 3/10/26 03:44, Ai Chao wrote: > Use a safer function strscpy() instead of strcpy() for copying to > arrays. > > Only idiomatic code replacement, and no functional changes. It is a functional change since it calls a new routine. Get rid of this line from change log. How did you test this patch? I am curious because of you are describing the change as "idiomatic code replacement" > > Signed-off-by: Ai Chao <aichao@kylinos.cn> > --- > drivers/usb/usbip/vhci_sysfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c > index bfc10f665e52..5bc8c47788d4 100644 > --- a/drivers/usb/usbip/vhci_sysfs.c > +++ b/drivers/usb/usbip/vhci_sysfs.c > @@ -463,7 +463,7 @@ static void set_status_attr(int id) > > status = status_attrs + id; > if (id == 0) > - strcpy(status->name, "status"); > + strscpy(status->name, "status"); > else > snprintf(status->name, MAX_STATUS_NAME+1, "status.%d", id); > status->attr.attr.name = status->name; thanks, -- Shuah
On Tue, Mar 10, 2026 at 04:10:20PM -0600, Shuah Khan wrote: > On 3/10/26 03:44, Ai Chao wrote: > > Use a safer function strscpy() instead of strcpy() for copying to > > arrays. > > > > Only idiomatic code replacement, and no functional changes. > > It is a functional change since it calls a new routine. Get rid > of this line from change log. > > How did you test this patch? I am curious because of you are > describing the change as "idiomatic code replacement" > I liked the commit message... To me it says that patch affect runtime. It doesn' fix any bugs or introduce any bugs. Too often these changes are sold as a "potential" bugfix, which means people haven't bothered to check whether it fixes a bug or not. It's the right thing to add a note under the --- cut off that the patch hasn't been tested. Testing isn't required for this sort of patch but a note is good so reviewers will know to be careful. regards, dan carpenter
On 3/11/26 01:22, Dan Carpenter wrote: > On Tue, Mar 10, 2026 at 04:10:20PM -0600, Shuah Khan wrote: >> On 3/10/26 03:44, Ai Chao wrote: >>> Use a safer function strscpy() instead of strcpy() for copying to >>> arrays. >>> >>> Only idiomatic code replacement, and no functional changes. >> >> It is a functional change since it calls a new routine. Get rid >> of this line from change log. >> >> How did you test this patch? I am curious because of you are >> describing the change as "idiomatic code replacement" >> > > I liked the commit message... To me it says that patch affect > runtime. It doesn' fix any bugs or introduce any bugs. Too often > these changes are sold as a "potential" bugfix, which means people > haven't bothered to check whether it fixes a bug or not. > > It's the right thing to add a note under the --- cut off that the > patch hasn't been tested. Testing isn't required for this sort > of patch but a note is good so reviewers will know to be careful. I would like to see some sort of testing for patches like this one. It isn't hard to test this change. thanks, -- Shuah
On Tue, Mar 24, 2026 at 03:34:03PM -0600, Shuah Khan wrote: > On 3/11/26 01:22, Dan Carpenter wrote: > > On Tue, Mar 10, 2026 at 04:10:20PM -0600, Shuah Khan wrote: > > > On 3/10/26 03:44, Ai Chao wrote: > > > > Use a safer function strscpy() instead of strcpy() for copying to > > > > arrays. > > > > > > > > Only idiomatic code replacement, and no functional changes. > > > > > > It is a functional change since it calls a new routine. Get rid > > > of this line from change log. > > > > > > How did you test this patch? I am curious because of you are > > > describing the change as "idiomatic code replacement" > > > > > > > I liked the commit message... To me it says that patch affect > > runtime. It doesn' fix any bugs or introduce any bugs. Too often > > these changes are sold as a "potential" bugfix, which means people > > haven't bothered to check whether it fixes a bug or not. > > > > It's the right thing to add a note under the --- cut off that the > > patch hasn't been tested. Testing isn't required for this sort > > of patch but a note is good so reviewers will know to be careful. > > I would like to see some sort of testing for patches like this one. > It isn't hard to test this change. It would take me a while to figure out how to test this. :P Presumably, it's: sudo ./tools/testing/selftests/drivers/usb/usbip/usbip_test.sh -b<busid> -p tools/usb/usbip/ but I couldn't figure out what to supply for a busid... Does kernel-ci do usbip testing? regards, dan carpenter
© 2016 - 2026 Red Hat, Inc.