summaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-09-09 18:37:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-10 16:29:01 -0400
commit9d3e3c705eb395528fd8f17208c87581b134da48 (patch)
tree6d96f106f1d7704fdb800321ab03e1dd111b5ad0 /scripts/checkpatch.pl
parentfe043ea1205695f2224b279ac9f5cc1742d18f0b (diff)
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: Joe Perches <joe@perches.com> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl14
1 files changed, 8 insertions, 6 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 984a82e6b188..1629e3513f0d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3448,13 +3448,15 @@ sub process {
3448 } 3448 }
3449 } 3449 }
3450 3450
3451# # no BUG() or BUG_ON() 3451# avoid BUG() or BUG_ON()
3452# if ($line =~ /\b(BUG|BUG_ON)\b/) { 3452 if ($line =~ /\b(?:BUG|BUG_ON)\b/) {
3453# print "Try to use WARN_ON & Recovery code rather than BUG() or BUG_ON()\n"; 3453 my $msg_type = \&WARN;
3454# print "$herecurr"; 3454 $msg_type = \&CHK if ($file);
3455# $clean = 0; 3455 &{$msg_type}("AVOID_BUG",
3456# } 3456 "Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . $herecurr);
3457 }
3457 3458
3459# avoid LINUX_VERSION_CODE
3458 if ($line =~ /\bLINUX_VERSION_CODE\b/) { 3460 if ($line =~ /\bLINUX_VERSION_CODE\b/) {
3459 WARN("LINUX_VERSION_CODE", 3461 WARN("LINUX_VERSION_CODE",
3460 "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); 3462 "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);