linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usbip: vudc: Convert snprintf() to sysfs_emit()
@ 2022-10-01 14:56 Jules Irenge
  2022-10-03 17:19 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Jules Irenge @ 2022-10-01 14:56 UTC (permalink / raw)
  To: shuah; +Cc: valentina.manea.m, gregkh, linux-usb

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()

Signed-off-by: Jules Irenge <jules.irenge@postgrad.manchester.ac.uk>
---
 drivers/usb/usbip/vudc_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index c95e6b2bfd32..907a43a00896 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -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);
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usbip: vudc: Convert snprintf() to sysfs_emit()
  2022-10-01 14:56 [PATCH] usbip: vudc: Convert snprintf() to sysfs_emit() Jules Irenge
@ 2022-10-03 17:19 ` Shuah Khan
  0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2022-10-03 17:19 UTC (permalink / raw)
  To: Jules Irenge, shuah, gregkh; +Cc: valentina.manea.m, linux-usb, Shuah Khan

On 10/1/22 08:56, Jules Irenge wrote:
> 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()
> 
> Signed-off-by: Jules Irenge <jules.irenge@postgrad.manchester.ac.uk>
> ---
>   drivers/usb/usbip/vudc_sysfs.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
> index c95e6b2bfd32..907a43a00896 100644
> --- a/drivers/usb/usbip/vudc_sysfs.c
> +++ b/drivers/usb/usbip/vudc_sysfs.c
> @@ -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.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

Greg, Please pick this up.

thanks,
-- Shuah



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-03 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01 14:56 [PATCH] usbip: vudc: Convert snprintf() to sysfs_emit() Jules Irenge
2022-10-03 17:19 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).