[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTinfjGB_1CaWNQHynFWK5Tki9BJCW3oeOaY68py9@mail.gmail.com>
Date: Wed, 25 Aug 2010 08:10:20 +0800
From: Changli Gao <xiaosuo@...il.com>
To: Joe Perches <joe@...ches.com>
Cc: akpm@...ux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib: fix scnprintf() if @size is == 0
On Wed, Aug 25, 2010 at 8:03 AM, Joe Perches <joe@...ches.com> wrote:
>
> Isn't simpler to check size at the beginning of the function?
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 7af9d84..779236f 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1505,6 +1505,9 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...)
> va_list args;
> int i;
>
> + if (!size)
> + return 0;
> +
It is a rare case, so don't slow down the normal users.
> va_start(args, fmt);
> i = vsnprintf(buf, size, fmt, args);
> va_end(args);
>
>
>
--
Regards,
Changli Gao(xiaosuo@...il.com)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists