aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mladek <[email protected]>2019-04-17 13:53:46 +0200
committerPetr Mladek <[email protected]>2019-04-26 16:19:59 +0200
commit798cc27a305e7b35b7bff3a71257e6fe57f70bc1 (patch)
tree86a643ee1e15308b36b050df361f9be8a6a5c118
parent45c3e93d751ea50861c796da3cbfc848fa6ddf55 (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/[email protected] To: Rasmus Villemoes <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: "Tobin C . Harding" <[email protected]> Cc: Joe Perches <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: [email protected] Cc: Kees Cook <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Petr Mladek <[email protected]>
-rw-r--r--lib/vsprintf.c17
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,
return widen_string(buf, buf - buf_start, end, spec);
}
+static char *kobject_string(char *buf, char *end, void *ptr,
+ struct printf_spec spec, const char *fmt)
+{
+ switch (fmt[1]) {
+ case 'F':
+ return device_node_string(buf, end, ptr, spec, fmt + 1);
+ }
+
+ return ptr_to_id(buf, end, ptr, spec);
+}
+
/*
* Show a '%p' thing. A kernel extension is that the '%p' is followed
* 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,
case 'G':
return flags_string(buf, end, ptr, fmt);
case 'O':
- switch (fmt[1]) {
- case 'F':
- return device_node_string(buf, end, ptr, spec, fmt + 1);
- }
- break;
+ return kobject_string(buf, end, ptr, spec, fmt);
case 'x':
return pointer_string(buf, end, ptr, spec);
}