Commit 9d3e3c70 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: add warning on BUG/BUG_ON use

Using BUG/BUG_ON crashes the kernel and is just unfriendly.

Enable code that emits a warning on BUG/BUG_ON use.

Make the code emit the message at WARNING level when scanning a patch and
at CHECK level when scanning files so that script users don't feel an
obligation to fix code that might be above their pay grade.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Tested-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fe043ea1
...@@ -3448,13 +3448,15 @@ sub process { ...@@ -3448,13 +3448,15 @@ sub process {
} }
} }
# # no BUG() or BUG_ON() # avoid BUG() or BUG_ON()
# if ($line =~ /\b(BUG|BUG_ON)\b/) { if ($line =~ /\b(?:BUG|BUG_ON)\b/) {
# print "Try to use WARN_ON & Recovery code rather than BUG() or BUG_ON()\n"; my $msg_type = \&WARN;
# print "$herecurr"; $msg_type = \&CHK if ($file);
# $clean = 0; &{$msg_type}("AVOID_BUG",
# } "Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . $herecurr);
}
# avoid LINUX_VERSION_CODE
if ($line =~ /\bLINUX_VERSION_CODE\b/) { if ($line =~ /\bLINUX_VERSION_CODE\b/) {
WARN("LINUX_VERSION_CODE", WARN("LINUX_VERSION_CODE",
"LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment