diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-03 20:46:17 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-03 20:46:17 +0100 |
commit | d97106ab53f812910a62d18afb9dbe882819c1ba (patch) | |
tree | edd1a2c287b7d98ee7b62e7ea6457c8a10abe016 /lib | |
parent | get rid of special-casing the /sbin/loader on alpha (diff) | |
download | linux-d97106ab53f812910a62d18afb9dbe882819c1ba.tar.xz linux-d97106ab53f812910a62d18afb9dbe882819c1ba.zip |
Make %p print '(null)' for NULL pointers
Before, when we only ever printed out the pointer value itself, a NULL
pointer would never cause issues and might as well be printed out as
just its numeric value.
However, with the extended %p formats, especially %pR, we might validly
want to print out resources for debugging. And sometimes they don't
even exist, and the resource pointer is just NULL. Print it out as
such, rather than oopsing.
This is a more generic version of a patch done by Trent Piepho (catching
all %p cases rather than just %pR, and using "(null)" instead of
"[NULL]" to match glibc).
Requested-by: Trent Piepho <xyzzy@speakeasy.org>
Acked-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 3b777025d876..98d632277ca8 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -661,6 +661,9 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width, */ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags) { + if (!ptr) + return string(buf, end, "(null)", field_width, precision, flags); + switch (*fmt) { case 'F': ptr = dereference_function_descriptor(ptr); |