diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-14 11:14:29 -0600 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-14 11:14:29 -0600 |
commit | 899552d6e84babd24611fd36ac7051068cb1eb2d (patch) | |
tree | 9a02d66b74a0a9267bbf6637765517f5e8558497 /scripts/coccinelle/misc/bugon.cocci | |
parent | 3b7b3e6ec5f56118046594d3c62469e7d1d0aadd (diff) | |
parent | 5a5da78b3a48120d942c8a18ecc645f6acdf7da6 (diff) | |
download | op-kernel-dev-899552d6e84babd24611fd36ac7051068cb1eb2d.zip op-kernel-dev-899552d6e84babd24611fd36ac7051068cb1eb2d.tar.gz |
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull misc kbuild updates from Michal Marek:
"This is the non-critical part of kbuild for 3.17-rc1:
- make help hint to use make -s with make kernelrelease et al.
- moved a kbuild document to Documentation/kbuild where it belongs
- four new Coccinelle scripts, one dropped and one fixed
- new make kselftest target to run various tests on the kernel"
* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
kbuild: kselftest - new make target to build and run kernel selftests
Coccinelle: Script to replace if and BUG with BUG_ON
Coccinelle: Script to detect incorrect argument to sizeof
Coccinelle: Script to use ARRAY_SIZE instead of division of two sizeofs
Coccinelle: Script to detect cast after memory allocation
coccinelle/null: solve parse error
Documentation: headers_install.txt is part of kbuild
kbuild: make -s should be used with kernelrelease/kernelversion/image_name
Diffstat (limited to 'scripts/coccinelle/misc/bugon.cocci')
-rw-r--r-- | scripts/coccinelle/misc/bugon.cocci | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/coccinelle/misc/bugon.cocci b/scripts/coccinelle/misc/bugon.cocci new file mode 100644 index 0000000..556456c --- /dev/null +++ b/scripts/coccinelle/misc/bugon.cocci @@ -0,0 +1,62 @@ +/// Use BUG_ON instead of a if condition followed by BUG. +/// +//# This makes an effort to find cases where BUG() follows an if +//# condition on an expression and replaces the if condition and BUG() +//# with a BUG_ON having the conditional expression of the if statement +//# as argument. +// +// Confidence: High +// Copyright: (C) 2014 Himangi Saraogi. GPLv2. +// Comments: +// Options: --no-includes, --include-headers + +virtual patch +virtual context +virtual org +virtual report + +//---------------------------------------------------------- +// For context mode +//---------------------------------------------------------- + +@depends on context@ +expression e; +@@ + +*if (e) BUG(); + +//---------------------------------------------------------- +// For patch mode +//---------------------------------------------------------- + +@depends on patch@ +expression e; +@@ + +-if (e) BUG(); ++BUG_ON(e); + +//---------------------------------------------------------- +// For org and report mode +//---------------------------------------------------------- + +@r@ +expression e; +position p; +@@ + + if (e) BUG@p (); + +@script:python depends on org@ +p << r.p; +@@ + +coccilib.org.print_todo(p[0], "WARNING use BUG_ON") + +@script:python depends on report@ +p << r.p; +@@ + +msg="WARNING: Use BUG_ON" +coccilib.report.print_report(p[0], msg) + |