[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <151790891868.9432.1307772484552574756.stgit@warthog.procyon.org.uk>
Date: Tue, 06 Feb 2018 09:21:58 +0000
From: David Howells <dhowells@...hat.com>
To: torvalds@...ux-foundation.org
Cc: dhowells@...hat.com, peterz@...radead.org,
linux-kernel@...r.kernel.org, me@...in.cc
Subject: [PATCH] printk: Print error pointers as negative integers for %p
The new hashing feature of unadorned printk("%p") makes it hard to spot if
the pointer actually carries an error value. Make %p print any pointer
that matches IS_ERR() as a negative integer.
Should I set SMALL and the field_width as well, I wonder?
Signed-off-by: David Howells <dhowells@...hat.com>
---
lib/vsprintf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 77ee6ced11b1..d87adca33b12 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1705,6 +1705,12 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
return string(buf, end, "(ptrval)", spec);
}
+ if (IS_ERR(ptr)) {
+ spec.type = FORMAT_TYPE_INT;
+ spec.flags |= SIGN;
+ return number(buf, end, PTR_ERR(ptr), spec);
+ }
+
#ifdef CONFIG_64BIT
hashval = (unsigned long)siphash_1u64((u64)ptr, &ptr_key);
/*
Powered by blists - more mailing lists