Skip to contentSkip to conversation

x86: traps.c: use format string with panic() call

PATCH New Rasmus Villemoes 2 participants 2 messages Oct 26, 2018 – Oct 29, 2018 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: traps.c: use format string with panic() call

Building with -Wformat-nonliteral gives

arch/x86/kernel/traps.c:334:2: warning: format not a string literal and no format arguments [-Wformat-nonliteral]
panic(message);

handle_stack_overflow can only be called from two places (kernel/traps.c and via inline asm in mm/fault.c), in both cases with a string not containing format specifiers, but we might as well silence this warning using "%s" as format string.

---
 arch/x86/kernel/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/traps.c +1 -1
index 8f6dcd88202e..9b7c4ca8f0a7 100644
@@ -306,7 +306,7 @@ __visible void __noreturn handle_stack_overflow(const char *message,
 	die(message, regs, 0);
 
 	/* Be absolutely certain we don't return. */
-	panic(message);
+	panic("%s", message);
 }
 #endif
 
Signature · 1 line
2.19.1.6.gbde171bbf5
#1 lore raw

[tip:x86/urgent] x86/traps: Use format string with panic() call

x86/traps: Use format string with panic() call
Commit-ID:  2022cceb4e30f1bb4c84d40ffa705aa8d8d68adb
Gitweb:     https://git.kernel.org/tip/2022cceb4e30f1bb4c84d40ffa705aa8d8d68adb
Author:     Rasmus Villemoes <[email protected]>
AuthorDate: Sat, 27 Oct 2018 00:20:04 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 29 Oct 2018 07:19:26 +0100

x86/traps: Use format string with panic() call

Building with -Wformat-nonliteral gives:

arch/x86/kernel/traps.c:334:2: warning: format not a string literal and no format arguments [-Wformat-nonliteral]

    panic(message);

handle_stack_overflow() can only be called from two places (kernel/traps.c and via inline asm in mm/fault.c), in both cases with a string not containing format specifiers, so we might as well silence this warning using "%s" as a format string.

---
 arch/x86/kernel/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/traps.c +1 -1
index 8f6dcd88202e..9b7c4ca8f0a7 100644
@@ -306,7 +306,7 @@ __visible void __noreturn handle_stack_overflow(const char *message,
 	die(message, regs, 0);
 
 	/* Be absolutely certain we don't return. */
-	panic(message);
+	panic("%s", message);
 }
 #endif