lkml.org 
[lkml]   [2018]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] printk: Print error pointers as negative integers for %p
From
Date
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@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);
/*
\
 
 \ /
  Last update: 2018-02-06 10:22    [W:0.060 / U:1.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site