]> git.baikalelectronics.ru Git - kernel.git/commit
Make %p print '(null)' for NULL pointers
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 3 Jan 2009 19:46:17 +0000 (11:46 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 3 Jan 2009 19:46:17 +0000 (11:46 -0800)
commitf077d33b81c38c52e484d3b5b7ebd6ca9206bcdb
treeedd1a2c287b7d98ee7b62e7ea6457c8a10abe016
parentd2e3d901b9aacf1b7921dd73d152d4de6da0a7ee
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>
lib/vsprintf.c