diff options
author | Petr Mladek <pmladek@suse.com> | 2019-04-17 07:53:45 -0400 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2019-04-26 10:19:41 -0400 |
commit | 45c3e93d751ea50861c796da3cbfc848fa6ddf55 (patch) | |
tree | d039b472da9cbefa14ed11bbeb4d07880af832bc /lib/vsprintf.c | |
parent | f00cc102b862be688fe090aec30e08d61a8f5e63 (diff) |
vsprintf: Factor out %pV handler as va_format()
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.
Link: http://lkml.kernel.org/r/20190417115350.20479-6-pmladek@suse.com
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Tobin C . Harding" <me@tobin.cc>
Cc: Joe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r-- | lib/vsprintf.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8ca29bc0d786..12b71a4d4613 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -1520,6 +1520,17 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, | |||
1520 | return buf; | 1520 | return buf; |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | static char *va_format(char *buf, char *end, struct va_format *va_fmt) | ||
1524 | { | ||
1525 | va_list va; | ||
1526 | |||
1527 | va_copy(va, *va_fmt->va); | ||
1528 | buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va); | ||
1529 | va_end(va); | ||
1530 | |||
1531 | return buf; | ||
1532 | } | ||
1533 | |||
1523 | static noinline_for_stack | 1534 | static noinline_for_stack |
1524 | char *uuid_string(char *buf, char *end, const u8 *addr, | 1535 | char *uuid_string(char *buf, char *end, const u8 *addr, |
1525 | struct printf_spec spec, const char *fmt) | 1536 | struct printf_spec spec, const char *fmt) |
@@ -2046,15 +2057,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
2046 | case 'U': | 2057 | case 'U': |
2047 | return uuid_string(buf, end, ptr, spec, fmt); | 2058 | return uuid_string(buf, end, ptr, spec, fmt); |
2048 | case 'V': | 2059 | case 'V': |
2049 | { | 2060 | return va_format(buf, end, ptr); |
2050 | va_list va; | ||
2051 | |||
2052 | va_copy(va, *((struct va_format *)ptr)->va); | ||
2053 | buf += vsnprintf(buf, end > buf ? end - buf : 0, | ||
2054 | ((struct va_format *)ptr)->fmt, va); | ||
2055 | va_end(va); | ||
2056 | return buf; | ||
2057 | } | ||
2058 | case 'K': | 2061 | case 'K': |
2059 | return restricted_pointer(buf, end, ptr, spec); | 2062 | return restricted_pointer(buf, end, ptr, spec); |
2060 | case 'N': | 2063 | case 'N': |