提交 223e8f01 编写于 作者: S Seymour, Shane M 提交者: Greg Kroah-Hartman

sysfs.txt: update show method notes about sprintf/snprintf/scnprintf usage

Changed the documentation to allow sprintf() when the buffer
provided by sysfs cannot be overflowed. Explicitly say
snprintf() must never be used in a show function to format
data to be returned to user space.

Change based on a discussion about the patch
st: convert DRIVER_ATTR macros to DRIVER_ATTR_RO
Suggested-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NShane Seymour <shane.seymour@hp.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 64526370
...@@ -212,7 +212,10 @@ Other notes: ...@@ -212,7 +212,10 @@ Other notes:
- show() methods should return the number of bytes printed into the - 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 scnprintf().
- show() should always use scnprintf(). - 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().
- store() should return the number of bytes used from the buffer. If the - store() should return the number of bytes used from the buffer. If the
entire buffer has been used, just return the count argument. entire buffer has been used, just return the count argument.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册