]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] snprintf() commentary
authorAndrew Morton <akpm@osdl.org>
Fri, 6 Feb 2004 00:49:48 +0000 (16:49 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 6 Feb 2004 00:49:48 +0000 (16:49 -0800)
From: Paul Jackson <pj@sgi.com>

Explain the snprintf() return value.

lib/vsprintf.c

index da4398a3a6885d5afbd0ea04a3733b2fe714453e..fdc2f19e241c2467e5be6e82f8dd765111894d16 100644 (file)
@@ -234,6 +234,11 @@ static char * number(char * buf, char * end, unsigned long long num, int base, i
 * @fmt: The format string to use
 * @args: Arguments for the format string
 *
+* The return value is the number of characters which would be
+* generated for the given input, excluding the trailing null,
+* as per ISO C99.  If the return is greater than or equal to
+* @size, the resulting string is truncated.
+*
 * Call this function if you are already dealing with a va_list.
 * You probably want snprintf instead.
  */
@@ -482,6 +487,11 @@ EXPORT_SYMBOL(vsnprintf);
  * @size: The size of the buffer, including the trailing null space
  * @fmt: The format string to use
  * @...: Arguments for the format string
+ *
+ * The return value is the number of characters which would be
+ * generated for the given input, excluding the trailing null,
+ * as per ISO C99.  If the return is greater than or equal to
+ * @size, the resulting string is truncated.
  */
 int snprintf(char * buf, size_t size, const char *fmt, ...)
 {