lkml.org 
[lkml]   [2022]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 3/4] pwm: sysfs: Replace sprintf() with sysfs_emit()
On Wed, Sep 28, 2022 at 04:40:35PM +0300, Andy Shevchenko wrote:
> On Wed, Sep 28, 2022 at 02:28:41PM +0200, Thierry Reding wrote:
> > On Fri, Aug 26, 2022 at 08:07:15PM +0300, Andy Shevchenko wrote:
> > > For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
> > > instead of the raw sprintf() & co. This patch replaces such a
> > > sprintf() call straightforwardly with the new helper.
>
> > How exactly is sysfs_emit() safer here? In all of these cases, the
> > values that sprintf() writes are the only values that are written into
> > the buffer and we know that none of them exceed PAGE_SIZE. So the
> > additional checks that sysfs_emit() performs are useless.
>
> This is a recommended way to use sysfs_emit() mentioned in Documentation.
> Care to fix documentation?

For your convenience, Documentation/filesystems/sysfs.rst says:

- show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2022-09-28 16:00    [W:0.083 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site