lkml.org 
[lkml]   [2018]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v5 07/11] vsprintf: Factor out %pV handler as va_format()
    Date
    Move the code from the long pointer() function. We are going to add a check
    for the access to the address that will make it even more complicated.

    This patch does not change the existing behavior.

    Signed-off-by: Petr Mladek <pmladek@suse.com>
    ---
    lib/vsprintf.c | 22 +++++++++++++---------
    1 file changed, 13 insertions(+), 9 deletions(-)

    diff --git a/lib/vsprintf.c b/lib/vsprintf.c
    index 92793060bb1f..e58436ef9f7f 100644
    --- a/lib/vsprintf.c
    +++ b/lib/vsprintf.c
    @@ -1479,6 +1479,18 @@ 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)
    @@ -1927,15 +1939,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':
    --
    2.13.6
    \
     
     \ /
      Last update: 2018-04-25 13:16    [W:4.432 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site