projects/linux·commit 3a129cc2

vsprintf: avoid misleading "(null)" for %px

3a129cc2 · Adam Borowski <[email protected]> · 2018-02-04 18:45:21 +01:00

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/[email protected]
To: Sergey Senozhatsky <[email protected]>
To: Steven Rostedt <[email protected]>
To: [email protected]
Cc: Andrew Morton <[email protected]>
Cc: Joe Perches <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: "Roberts, William C" <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: David Laight <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Signed-off-by: Adam Borowski <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
Commit
3a129cc2151425e5aeb69aeb25fbc994ec738137
Parents
ab486bc9

Changes

1 files changed · +1 −1

FileStatusAddDelContent
lib/vsprintf.cmodified+1−1View file

lib/vsprintf.c

View file
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 77ee6ce..d7a708f 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1849,7 +1849,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.