From b5f29c80b2f5776ff94880a119f578abaa245637 Mon Sep 17 00:00:00 2001 From: Changli Gao Date: Tue, 26 Oct 2010 14:22:50 -0700 Subject: [PATCH] --- yaml --- r: 217549 b: refs/heads/master c: b903c0b8899b46829a9b80ba55b61079b35940ec h: refs/heads/master i: 217547: 50b4b17cd3628f379656583cc3a4596b55aba3c1 v: v3 --- [refs] | 2 +- trunk/lib/vsprintf.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index ca48b067e639..7a47c0913aee 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5e0579812834ab7fa072db4a15ebdff68d62e2e7 +refs/heads/master: b903c0b8899b46829a9b80ba55b61079b35940ec diff --git a/trunk/lib/vsprintf.c b/trunk/lib/vsprintf.c index 8378c136b6e1..c150d3dafff4 100644 --- a/trunk/lib/vsprintf.c +++ b/trunk/lib/vsprintf.c @@ -1504,7 +1504,7 @@ EXPORT_SYMBOL(snprintf); * @...: Arguments for the format string * * The return value is the number of characters written into @buf not including - * the trailing '\0'. If @size is <= 0 the function returns 0. + * the trailing '\0'. If @size is == 0 the function returns 0. */ int scnprintf(char *buf, size_t size, const char *fmt, ...) @@ -1516,7 +1516,11 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...) i = vsnprintf(buf, size, fmt, args); va_end(args); - return (i >= size) ? (size - 1) : i; + if (likely(i < size)) + return i; + if (size != 0) + return size - 1; + return 0; } EXPORT_SYMBOL(scnprintf);