fuse: use sysfs_emit() instead of sprintf()
Subsystems (2)
PATCH 1/1 fuse: use sysfs_emit() instead of sprintf()
Follow the advice in Documentation/filesystems/sysfs.rst:show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space.
--- fs/fuse/cuse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/cuse.c +1 -1
@@ -581,7 +581,7 @@ static ssize_t cuse_class_waiting_show(struct device *dev, {struct cuse_conn *cc =dev_get_drvdata (dev); -return sprintf (buf,"%d\n" ,atomic_read (&cc->fc.num_waiting)); +return sysfs_emit (buf,"%d\n" ,atomic_read (&cc->fc.num_waiting)); } static DEVICE_ATTR(waiting, 0400, cuse_class_waiting_show, NULL);
Signature · 1 line
2.25.1
Quoted 4 lines · chen zhang
Follow the advice in
Documentation/filesystems/sysfs.rst:show()should only usesysfs_emit()orsysfs_emit_at()when formatting the value to be returned to user space.
I think it'd be useful here to include why too (eg that it handles the page-sized buffer limit and prevents potential buffer overflow)
Quoted 2 lines
Signed-off-by chen zhang <[email protected]>
nit: the convention (at least as far as I can tell :)) is for signed-off-by names to be capitalized
Quoted 9 lines
--- fs/fuse/cuse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/fuse/cuse.c +0
-0
fs/fuse/cuse.c static ssize_t cuse_class_waiting_show(struct device *dev, · line 586
Quoted 7 lines
fs/fuse/cuse.c +1
-1@@ -581,7 +581,7 @@ static ssize_t cuse_class_waiting_show(struct device *dev, {struct cuse_conn *cc =dev_get_drvdata (dev); -return sprintf (buf,"%d\n" ,atomic_read (&cc->fc.num_waiting)); +return sysfs_emit (buf,"%d\n" ,atomic_read (&cc->fc.num_waiting)); } static DEVICE_ATTR(waiting, 0400, cuse_class_waiting_show, NULL);
btw, cpu_list_show() in fuse/virtio_fs.c could be converted to use sysfs_emit_at() as well.
Thanks,
Joanne
Quoted 4 lines
fs/fuse/cuse.c +0
-1--2.25.1