usbip: vudc: Convert snprintf() to sysfs_emit()
authorJules Irenge <jbi.octave@gmail.com>
Sat, 1 Oct 2022 14:56:33 +0000 (15:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Oct 2022 11:20:49 +0000 (13:20 +0200)
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>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/YzhVIaNGdM33pcts@octinomon
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usbip/vudc_sysfs.c

index c95e6b2..907a43a 100644 (file)
@@ -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);