Messages in this thread | | | Subject | Re: [PATCH v6 5/9] vsprintf: Factor out %pV handler as va_format() | From | Joe Perches <> | Date | Fri, 08 Feb 2019 09:11:17 -0800 |
| |
On Fri, 2019-02-08 at 16:23 +0100, Petr Mladek wrote: > Move the code from the long pointer() function. We are going to improve > error handling that will make it more complicated. > > This patch does not change the existing behavior.
But doesn't this increase stack use? %pV is recursive and increasing the stack is undesired for this use.
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c [] > @@ -1519,6 +1519,17 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, > return buf; > } > > +static char *va_format(char *buf, char *end, struct va_format *va_fmt) > +{ > + va_list va; > + > + va_copy(va, *va_fmt->va); > + buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va); > + va_end(va); > + > + return buf; > +} > + > static noinline_for_stack > char *uuid_string(char *buf, char *end, const u8 *addr, > struct printf_spec spec, const char *fmt) > @@ -2046,15 +2057,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, > case 'U': > return uuid_string(buf, end, ptr, spec, fmt); > case 'V': > - { > - va_list va; > - > - va_copy(va, *((struct va_format *)ptr)->va); > - buf += vsnprintf(buf, end > buf ? end - buf : 0, > - ((struct va_format *)ptr)->fmt, va); > - va_end(va); > - return buf; > - } > + return va_format(buf, end, ptr); > case 'K': > return restricted_pointer(buf, end, ptr, spec); > case 'N':
| |