From dd382b3cdb99e0e4f754557df52d0300912c4c04 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 5 Feb 2004 16:49:48 -0800 Subject: [PATCH] [PATCH] snprintf() commentary From: Paul Jackson Explain the snprintf() return value. --- lib/vsprintf.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index da4398a3a6885..fdc2f19e241c2 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -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, ...) { -- 2.53.0