Re: [PATCH] sysfs: Add sysfs_emit to replace sprintf to PAGE_SIZE buffers.
From: Denis Efremov
Date: Sat Aug 29 2020 - 17:57:38 EST
>
> Anyway, this will need updating, likely with better examples.
>
> diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystems/sysfs.rst
> index ab0f7795792b..13c7a86fa6c8 100644
> --- a/Documentation/filesystems/sysfs.rst
> +++ b/Documentation/filesystems/sysfs.rst
> @@ -242,12 +242,9 @@ Other notes:
> is 4096.
>
> - show() methods should return the number of bytes printed into the
> - buffer. This is the return value of scnprintf().
> + buffer. This is the return value of sysfs_emit().
>
> -- show() must not use snprintf() when formatting the value to be
> - returned to user space. If you can guarantee that an overflow
> - will never happen you can use sprintf() otherwise you must use
> - scnprintf().
> +- show() methods should only use sysfs_emit to format output.
>
I think it's good to reflect in docs that sysfs_emit_at/sysfs_emit_pos is
only for "legacy" code and should not be used in new code (checkpatch.pl warning?)
because of sysfs design principles.
And something about newlines "General rule is to add newlines at the end of output."
Thanks,
Denis