linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sysfs.txt: update show method notes about sprintf/snprintf/scnprintf usage
@ 2015-06-25  0:55 Seymour, Shane M
       [not found] ` <DDB9C85B850785449757F9914A034FCB3F8EA364-MCKW7lC+H9ISZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Seymour, Shane M @ 2015-06-25  0:55 UTC (permalink / raw)
  To: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> (gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org)


Changed the documentation to allow sprintf() for small
single values and 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: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
Signed-off-by: Shane Seymour <shane.seymour-VXdhtT5mjnY@public.gmane.org>
---
--- a/Documentation/filesystems/sysfs.txt	2015-06-22 14:18:40.278620871 -0500
+++ b/Documentation/filesystems/sysfs.txt	2015-06-24 13:42:21.344446532 -0500
@@ -212,7 +212,9 @@ Other notes:
 - show() methods should return the number of bytes printed into the
   buffer. This is the return value of scnprintf().
 
-- show() should always use scnprintf().
+- show() must not use snprintf() when formatting a value to be
+  returned to user space. For small single values you can use
+  sprintf() otherwise you must use scnprintf().
 
 - store() should return the number of bytes used from the buffer. If the
   entire buffer has been used, just return the count argument.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-25  7:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-25  0:55 [PATCH] sysfs.txt: update show method notes about sprintf/snprintf/scnprintf usage Seymour, Shane M
     [not found] ` <DDB9C85B850785449757F9914A034FCB3F8EA364-MCKW7lC+H9ISZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
2015-06-25  1:59   ` Sergey Senozhatsky
2015-06-25  6:03     ` Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> (gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org)
2015-06-25  7:05       ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).