diff options
author | Petr Mladek <pmladek@suse.com> | 2019-04-17 07:53:46 -0400 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2019-04-26 10:19:59 -0400 |
commit | 798cc27a305e7b35b7bff3a71257e6fe57f70bc1 (patch) | |
tree | 86a643ee1e15308b36b050df361f9be8a6a5c118 /lib/vsprintf.c | |
parent | 45c3e93d751ea50861c796da3cbfc848fa6ddf55 (diff) |
vsprintf: Factor out %pO handler as kobject_string()
Move code from the long pointer() function. We are going to improve
error handling that will make it even more complicated.
This patch does not change the existing behavior.
Link: http://lkml.kernel.org/r/20190417115350.20479-7-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
Cc: Kees Cook <keescook@chromium.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 | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 12b71a4d4613..9817d171f608 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -1888,6 +1888,17 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, | |||
1888 | return widen_string(buf, buf - buf_start, end, spec); | 1888 | return widen_string(buf, buf - buf_start, end, spec); |
1889 | } | 1889 | } |
1890 | 1890 | ||
1891 | static char *kobject_string(char *buf, char *end, void *ptr, | ||
1892 | struct printf_spec spec, const char *fmt) | ||
1893 | { | ||
1894 | switch (fmt[1]) { | ||
1895 | case 'F': | ||
1896 | return device_node_string(buf, end, ptr, spec, fmt + 1); | ||
1897 | } | ||
1898 | |||
1899 | return ptr_to_id(buf, end, ptr, spec); | ||
1900 | } | ||
1901 | |||
1891 | /* | 1902 | /* |
1892 | * Show a '%p' thing. A kernel extension is that the '%p' is followed | 1903 | * Show a '%p' thing. A kernel extension is that the '%p' is followed |
1893 | * by an extra set of alphanumeric characters that are extended format | 1904 | * by an extra set of alphanumeric characters that are extended format |
@@ -2082,11 +2093,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
2082 | case 'G': | 2093 | case 'G': |
2083 | return flags_string(buf, end, ptr, fmt); | 2094 | return flags_string(buf, end, ptr, fmt); |
2084 | case 'O': | 2095 | case 'O': |
2085 | switch (fmt[1]) { | 2096 | return kobject_string(buf, end, ptr, spec, fmt); |
2086 | case 'F': | ||
2087 | return device_node_string(buf, end, ptr, spec, fmt + 1); | ||
2088 | } | ||
2089 | break; | ||
2090 | case 'x': | 2097 | case 'x': |
2091 | return pointer_string(buf, end, ptr, spec); | 2098 | return pointer_string(buf, end, ptr, spec); |
2092 | } | 2099 | } |