diff options
author | Joe Perches <joe@perches.com> | 2015-07-20 08:57:15 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2015-07-22 14:31:53 +1000 |
commit | 07ca487189bbf72043b5c53cb7dbcdc53cb667be (patch) | |
tree | c2d6ec8521a99cd2f37efa1504b133ea29d1bc4b | |
parent | 1aa6b3a31737ab87964d0a30820538ec5f9973f4 (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>
-rwxr-xr-x | scripts/checkpatch.pl | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c508b9afde6d..ceba782aa2b8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3448,13 +3448,15 @@ sub process { } } -# # no BUG() or BUG_ON() -# if ($line =~ /\b(BUG|BUG_ON)\b/) { -# print "Try to use WARN_ON & Recovery code rather than BUG() or BUG_ON()\n"; -# print "$herecurr"; -# $clean = 0; -# } +# avoid BUG() or BUG_ON() + if ($line =~ /\b(?:BUG|BUG_ON)\b/) { + my $msg_type = \&WARN; + $msg_type = \&CHK if ($file); + &{$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/) { WARN("LINUX_VERSION_CODE", "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); |