Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755762AbZCKKrT (ORCPT ); Wed, 11 Mar 2009 06:47:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754563AbZCKKrI (ORCPT ); Wed, 11 Mar 2009 06:47:08 -0400 Received: from yx-out-2324.google.com ([74.125.44.28]:29475 "EHLO yx-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752527AbZCKKrF (ORCPT ); Wed, 11 Mar 2009 06:47:05 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:message-id:from:to:cc:user-agent:mime-version:content-type; b=fjMDsBk/FmPHUJ7PEiz+xHYUkRbRkn1vWRs+waEDi10asGW1v7jEmMOionvCJIUJ7C ZkRS+34BDJdP4MkBUXzcQr5rp9+Kk1lfgFOgRL1qLrClz7LRQ8WZI5lh51YNn4HvoAuo gR/SQQKvlTn2r0ImZ/6sBi3lyk9gvpRdIZXy8= Date: Wed, 11 Mar 2009 11:47:16 +0100 Message-ID: <87ljrccp57.wl%vmayatsk@redhat.com> From: Vitaly Mayatskikh To: linux-kernel@vger.kernel.org Cc: Linus Torvalds User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/22.3 Mule/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1920 Lines: 57 Forgot to sign-off... (v)scnprintf says it should return 0 when size is 0, but doesn't do so. Also size_t is unsigned, it can't be less then 0. Fix the code and comments. Signed-off-by: Vitaly Mayatskikh diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 0fbd012..8e75c7e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -947,7 +947,7 @@ EXPORT_SYMBOL(vsnprintf); * @args: Arguments for the format string * * The return value is the number of characters which have been written into - * the @buf not including the trailing '\0'. If @size is <= 0 the function + * the @buf not including the trailing '\0'. If @size is == 0 the function * returns 0. * * Call this function if you are already dealing with a va_list. @@ -958,7 +958,8 @@ EXPORT_SYMBOL(vsnprintf); int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) { int i; - + if (!size) + return 0; i=vsnprintf(buf,size,fmt,args); return (i >= size) ? (size - 1) : i; } @@ -998,7 +999,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, ...) @@ -1006,6 +1007,8 @@ int scnprintf(char * buf, size_t size, const char *fmt, ...) va_list args; int i; + if (!size) + return 0; va_start(args, fmt); i = vsnprintf(buf, size, fmt, args); va_end(args); -- wbr, Vitaly -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/