lkml.org 
[lkml]   [2021]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject回复: [PATCH] tty: vt: replace snprintf in sh ow functions with sysfs emit
Date

>> show() must not use snprintf() when formatting the value to be
>> returned to user space.
>
>Again, who is making this "must" requirement?
>
>I, as the sysfs maintainer, am not saying that all existing show
>functions MUST be converted, so I find it hard to believe that someone
>else is...
>

According to Documentation/filesystems/sysfs.txt:
show() methods of device attributes should return the number
of bytes printed into the buffer. This is the return value of
scnprintf(). snprintf() returns the length the resulting string.

So, show() must not use snprintf() when formatting
the value to be returned to user space.
Also, use sysfs_emit directly makes more sense.

Thanks,

Qing

>
>>
>> Fix the following coccicheck warning:
>> drivers/tty/vt/vt.c:3902: WARNING: use scnprintf or sprintf.
>> drivers/tty/vt/vt.c:3910: WARNING: use scnprintf or sprintf.
>
>Someone needs to change this warning to show the correct thing here.
>
>thanks,
>
>greg k-h
\
 
 \ /
  Last update: 2021-10-15 09:10    [W:0.147 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site