Skip to content

Commit

Permalink
usbip: vudc: Convert snprintf() to sysfs_emit()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Shuah Khan <[email protected]>
Link: https://lore.kernel.org/r/YzhVIaNGdM33pcts@octinomon
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
irenge authored and gregkh committed Oct 22, 2022
1 parent 375ac0b commit 13cc02f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/usbip/vudc_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 13cc02f

Please sign in to comment.