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 <dhowe...@redhat.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);
        /*

Reply via email to