Messages in this thread | | | From | Changli Gao <> | Date | Wed, 25 Aug 2010 08:10:20 +0800 | Subject | Re: [PATCH] lib: fix scnprintf() if @size is == 0 |
| |
On Wed, Aug 25, 2010 at 8:03 AM, Joe Perches <joe@perches.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@gmail.com) -- 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/
| |