Skip to contentSkip to conversation

x86/kernel: re-use %*ph specifier

PATCH RESEND In review Andy Shevchenko 2 participants 2 messages Oct 2, 2015 – Oct 11, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 x86/kernel: re-use %*ph specifier

%*ph specifier allows to dump data in hex format using the poiter to a buffer. This is suitable to use here.

---
 arch/x86/kernel/jump_label.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/jump_label.c +2 -2
index e565e0e..8da5254 100644
@@ -31,8 +31,8 @@ static void bug_at(unsigned char *ip, int line)
 	 * Something went wrong. Crash the box, as something could be
 	 * corrupting the kernel.
 	 */
-	pr_warning("Unexpected op at %pS [%p] (%02x %02x %02x %02x %02x) %s:%d\n",
-	       ip, ip, ip[0], ip[1], ip[2], ip[3], ip[4], __FILE__, line);
+	pr_warn("Unexpected op at %pS [%p] (%5ph) %s:%d\n",
+		ip, ip, ip, __FILE__, line);
 	BUG();
 }
 
Signature · 1 line
2.5.1
#1 lore raw
Quoted 13 lines · Andy Shevchenko

%*ph specifier allows to dump data in hex format using the poiter to a buffer. This is suitable to use here.

---
 arch/x86/kernel/jump_label.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/jump_label.c +0 -0
index e565e0e..8da5254 100644

arch/x86/kernel/jump_label.c static void bug_at(unsigned char *ip, int line) · line 35

Quoted 7 lines
arch/x86/kernel/jump_label.c +2 -2
@@ -31,8 +31,8 @@ static void bug_at(unsigned char *ip, int line)
 	 * Something went wrong. Crash the box, as something could be
 	 * corrupting the kernel.
 	 */
-	pr_warning("Unexpected op at %pS [%p] (%02x %02x %02x %02x %02x) %s:%d\n",
-	       ip, ip, ip[0], ip[1], ip[2], ip[3], ip[4], __FILE__, line);
+	pr_warn("Unexpected op at %pS [%p] (%5ph) %s:%d\n",
+		ip, ip, ip, __FILE__, line);

We really do not need the file printed here. We better have the message starting with "jumplabel: Unexpected ...." And it should not be a warning as we BUG() right after that. pr_crit() is probably the right choice, though I wonder whether we should panic() right away when that happens.

arch/x86/kernel/jump_label.c static void bug_at(unsigned char *ip, int line) · line 36

Quoted 1 line
arch/x86/kernel/jump_label.c +0 -0
 	BUG();

Thanks,

tglx