Skip to content

Commit

Permalink
lib/bug.c: make WARN implementation match the kernel/panic.c one
Browse files Browse the repository at this point in the history
There are a few issues with the exception based WARN implementation in
lib/bug.c:

- Inconsistent printk flags. The "cut here" line is printed at KERN_EMERG, so
  the console and all logged in users see the single line:

------------[ cut here ]------------

  for each WARN. Fix this so we print everything at KERN_WARNING to match the
  kernel/panic.c version.

- The lib/bug.c WARN would print "Badness at". Change it to match the
  kernel/panic.c version which prints "WARNING: at".

- Print the list of modules, similar to kernel/panic.c of modules, similar to
  kernel/panic.c

[[email protected]: coding-style fixes]
Signed-off-by: Anton Blanchard <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
antonblanchard authored and torvalds committed Aug 11, 2010
1 parent c7ff0d9 commit e2e7e09
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/bug.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)

bug = find_bug(bugaddr);

printk(KERN_EMERG "------------[ cut here ]------------\n");

file = NULL;
line = 0;
warning = 0;
Expand All @@ -156,19 +154,24 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)

if (warning) {
/* this is a WARN_ON rather than BUG/BUG_ON */
printk(KERN_WARNING "------------[ cut here ]------------\n");

if (file)
printk(KERN_ERR "Badness at %s:%u\n",
printk(KERN_WARNING "WARNING: at %s:%u\n",
file, line);
else
printk(KERN_ERR "Badness at %p "
printk(KERN_WARNING "WARNING: at %p "
"[verbose debug info unavailable]\n",
(void *)bugaddr);

print_modules();
show_regs(regs);
add_taint(BUG_GET_TAINT(bug));
return BUG_TRAP_TYPE_WARN;
}

printk(KERN_EMERG "------------[ cut here ]------------\n");

if (file)
printk(KERN_CRIT "kernel BUG at %s:%u!\n",
file, line);
Expand Down

0 comments on commit e2e7e09

Please sign in to comment.