mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Changli Gao <xiaosuo@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Changli Gao <xiaosuo@gmail.com>
Subject: [PATCH] lib: fix scnprintf() if @size is == 0
Date: Wed, 25 Aug 2010 07:35:02 +0800	[thread overview]
Message-ID: <1282692902-2981-1-git-send-email-xiaosuo@gmail.com> (raw)

scnprintf() should return 0 if @size is == 0. Update the comment for it,
as @size is unsigned.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
 lib/vsprintf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 7af9d84..0c66ae9 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1497,7 +1497,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, ...)
@@ -1509,7 +1509,7 @@ 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;
+	return (i >= size) ? (size != 0 ? (size - 1) : 0) : i;
 }
 EXPORT_SYMBOL(scnprintf);
 

             reply	other threads:[~2010-08-24 23:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 23:35 Changli Gao [this message]
2010-08-25  0:03 ` Joe Perches
2010-08-25  0:10   ` Changli Gao
2010-08-25  0:35     ` Joe Perches
2010-08-25  0:44       ` Changli Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1282692902-2981-1-git-send-email-xiaosuo@gmail.com \
    --to=xiaosuo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®