]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
vsprintf: avoid misleading "(null)" for %px
authorAdam Borowski <kilobyte@angband.pl>
Sun, 4 Feb 2018 17:45:21 +0000 (18:45 +0100)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 15 Mar 2018 13:27:19 +0000 (08:27 -0500)
BugLink: http://bugs.launchpad.net/bugs/1754297
Like %pK already does, print "00000000" instead.

This confused people -- the convention is that "(null)" means you tried to
dereference a null pointer as opposed to printing the address.

Link: http://lkml.kernel.org/r/20180204174521.21383-1-kilobyte@angband.pl
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Joe Perches <joe@perches.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: "Roberts, William C" <william.c.roberts@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Petr Mladek <pmladek@suse.com>
(cherry picked from commit 3a129cc2151425e5aeb69aeb25fbc994ec738137)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
lib/vsprintf.c

index 2b3af0b87a2e2026f6b322da8a38494208aa65b7..3dfa16c4581b01f0065208cb4179e7002047c8d2 100644 (file)
@@ -1873,7 +1873,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 {
        const int default_width = 2 * sizeof(void *);
 
-       if (!ptr && *fmt != 'K') {
+       if (!ptr && *fmt != 'K' && *fmt != 'x') {
                /*
                 * Print (null) with the same width as a pointer so it makes
                 * tabular output look nice.