usbip: vudc: Convert snprintf() to sysfs_emit()
Subsystems (2)
PATCH 1/1 usbip: vudc: Convert snprintf() to sysfs_emit()
Coccinnelle reports a warning
Warning: Use scnprintf or sprintf
Following the advice on kernel documentation
https://www.kernel.org/doc/html/latest/filesystems/sysfs.html
For show(device *...) functions we should only use sysfs_emit() or sysfs_emit_at() especially when formatting the value to be returned to user space. Convert snprintf() to sysfs_emit()
--- drivers/usb/usbip/vudc_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/usbip/vudc_sysfs.c +1 -1
@@ -242,7 +242,7 @@ static ssize_t usbip_status_show(struct device *dev, status = udc->ud.status;spin_unlock_irq (&udc->ud.lock); -return snprintf (out,PAGE_SIZE ,"%d\n" , status); +return sysfs_emit (out,"%d\n" , status); }static DEVICE_ATTR_RO (usbip_status);
Signature · 1 line
2.37.3
Quoted 20 lines · Jules Irenge
Coccinnelle reports a warning
Warning: Use scnprintf or sprintfFollowing the advice on kernel documentation
https://www.kernel.org/doc/html/latest/filesystems/sysfs.htmlFor
show(device *...)functions we should only usesysfs_emit()orsysfs_emit_at()especially when formatting the value to be returned to user space. Convertsnprintf()tosysfs_emit()Signed-off-by Jules Irenge <[email protected]>--- drivers/usb/usbip/vudc_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/usbip/vudc_sysfs.c +0
-0
drivers/usb/usbip/vudc_sysfs.c static ssize_t usbip_status_show(struct device *dev, · line 248
Quoted 8 lines
drivers/usb/usbip/vudc_sysfs.c +1
-1@@ -242,7 +242,7 @@ static ssize_t usbip_status_show(struct device *dev, status = udc->ud.status;spin_unlock_irq (&udc->ud.lock); -return snprintf (out,PAGE_SIZE ,"%d\n" , status); +return sysfs_emit (out,"%d\n" , status); }static DEVICE_ATTR_RO (usbip_status);
Looks good to me.
Greg, Please pick this up.
thanks,
-- Shuah