lkml.org 
[lkml]   [2020]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] sysfs: Add sysfs_emit to replace sprintf to PAGE_SIZE buffers.
Date

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

\
 
 \ /
  Last update: 2020-08-29 23:54    [W:0.039 / U:2.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site