diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-05 17:20:14 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-05 17:20:14 -0400 |
| commit | f43100ae39bfeb757b75835ef61f0c2c46c99348 (patch) | |
| tree | 620379bb9a2287975ee222c449cd69d31738096e /scripts | |
| parent | 27b4a1a9eac8b0f8958da67e4abe025b96e1a293 (diff) | |
| parent | 5e8e1cc0a1c36c8ff156ac1f04a16422bd4ed3ac (diff) | |
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6
* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6:
scripts/dtc: Fix a resource leak
Documentation: fix ubuntu distro name
MAINTAINERS: Update kbuild git URLs
Add support for the C variable in the coccicheck script
Add scripts/coccinelle/deref_null.cocci
Add scripts/coccinelle/err_cast.cocci
Add scripts/coccinelle/resource_size.cocci
Add scripts/coccinelle/alloc/kzalloc-simple.cocci
Add scripts/coccinelle/alloc/drop_kmalloc_cast.cocci
Add Documentation/coccinelle.txt
Add a target to use the Coccinelle checker
scripts: decodecode: remove bashisms
Makefile: clarify a comment
checkkconfigsymbols.sh: Kconfig symbols sometimes have lowercase letters
scripts: add nconf into gitignore file
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Makefile.help | 3 | ||||
| -rwxr-xr-x | scripts/checkkconfigsymbols.sh | 2 | ||||
| -rwxr-xr-x | scripts/coccicheck | 80 | ||||
| -rw-r--r-- | scripts/coccinelle/alloc/drop_kmalloc_cast.cocci | 67 | ||||
| -rw-r--r-- | scripts/coccinelle/alloc/kzalloc-simple.cocci | 82 | ||||
| -rw-r--r-- | scripts/coccinelle/deref_null.cocci | 293 | ||||
| -rw-r--r-- | scripts/coccinelle/err_cast.cocci | 56 | ||||
| -rw-r--r-- | scripts/coccinelle/resource_size.cocci | 93 | ||||
| -rwxr-xr-x | scripts/decodecode | 10 | ||||
| -rw-r--r-- | scripts/dtc/fstree.c | 1 | ||||
| -rw-r--r-- | scripts/kconfig/.gitignore | 1 |
11 files changed, 682 insertions, 6 deletions
diff --git a/scripts/Makefile.help b/scripts/Makefile.help new file mode 100644 index 000000000000..d03608f5db04 --- /dev/null +++ b/scripts/Makefile.help | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | |||
| 2 | checker-help: | ||
| 3 | @echo ' coccicheck - Check with Coccinelle.' | ||
diff --git a/scripts/checkkconfigsymbols.sh b/scripts/checkkconfigsymbols.sh index 46be3c5a62b7..2ca49bb31efc 100755 --- a/scripts/checkkconfigsymbols.sh +++ b/scripts/checkkconfigsymbols.sh | |||
| @@ -14,7 +14,7 @@ find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while | |||
| 14 | do | 14 | do |
| 15 | # Output the bare Kconfig variable and the filename; the _MODULE part at | 15 | # Output the bare Kconfig variable and the filename; the _MODULE part at |
| 16 | # the end is not removed here (would need perl an not-hungry regexp for that). | 16 | # the end is not removed here (would need perl an not-hungry regexp for that). |
| 17 | sed -ne 's!^.*\<\(UML_\)\?CONFIG_\([0-9A-Z_]\+\).*!\2 '$i'!p' < $i | 17 | sed -ne 's!^.*\<\(UML_\)\?CONFIG_\([0-9A-Za-z_]\+\).*!\2 '$i'!p' < $i |
| 18 | done | \ | 18 | done | \ |
| 19 | # Smart "sort|uniq" implemented in awk and tuned to collect the names of all | 19 | # Smart "sort|uniq" implemented in awk and tuned to collect the names of all |
| 20 | # files which use a given symbol | 20 | # files which use a given symbol |
diff --git a/scripts/coccicheck b/scripts/coccicheck new file mode 100755 index 000000000000..b8bcf1f7bed7 --- /dev/null +++ b/scripts/coccicheck | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | SPATCH="`which ${SPATCH:=spatch}`" | ||
| 4 | |||
| 5 | if [ "$C" = "1" -o "$C" = "2" ]; then | ||
| 6 | ONLINE=1 | ||
| 7 | |||
| 8 | # This requires Coccinelle >= 0.2.3 | ||
| 9 | # FLAGS="-ignore_unknown_options -very_quiet" | ||
| 10 | # OPTIONS=$* | ||
| 11 | |||
| 12 | # Workaround for Coccinelle < 0.2.3 | ||
| 13 | FLAGS="-I $srctree/include -very_quiet" | ||
| 14 | shift $(( $# - 1 )) | ||
| 15 | OPTIONS=$1 | ||
| 16 | else | ||
| 17 | ONLINE=0 | ||
| 18 | FLAGS="-very_quiet" | ||
| 19 | fi | ||
| 20 | |||
| 21 | if [ ! -x "$SPATCH" ]; then | ||
| 22 | echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/' | ||
| 23 | exit 1 | ||
| 24 | fi | ||
| 25 | |||
| 26 | if [ "$MODE" = "" ] ; then | ||
| 27 | if [ "$ONLINE" = "0" ] ; then | ||
| 28 | echo 'You have not explicitly specify the mode to use. Fallback to "report".' | ||
| 29 | echo 'You can specify the mode with "make coccicheck MODE=<mode>"' | ||
| 30 | echo 'Available modes are: report, patch, context, org' | ||
| 31 | fi | ||
| 32 | MODE="report" | ||
| 33 | fi | ||
| 34 | |||
| 35 | if [ "$ONLINE" = "0" ] ; then | ||
| 36 | echo '' | ||
| 37 | echo 'Please check for false positives in the output before submitting a patch.' | ||
| 38 | echo 'When using "patch" mode, carefully review the patch before submitting it.' | ||
| 39 | echo '' | ||
| 40 | fi | ||
| 41 | |||
| 42 | coccinelle () { | ||
| 43 | COCCI="$1" | ||
| 44 | |||
| 45 | OPT=`grep "Option" $COCCI | cut -d':' -f2` | ||
| 46 | |||
| 47 | # The option '-parse_cocci' can be used to syntaxically check the SmPL files. | ||
| 48 | # | ||
| 49 | # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null | ||
| 50 | |||
| 51 | if [ "$ONLINE" = "0" ] ; then | ||
| 52 | |||
| 53 | FILE=`echo $COCCI | sed "s|$srctree/||"` | ||
| 54 | |||
| 55 | echo "Processing `basename $COCCI` with option(s) \"$OPT\"" | ||
| 56 | echo 'Message example to submit a patch:' | ||
| 57 | |||
| 58 | sed -e '/\/\/\//!d' -e 's|^///||' $COCCI | ||
| 59 | |||
| 60 | echo ' The semantic patch that makes this change is available' | ||
| 61 | echo " in $FILE." | ||
| 62 | echo '' | ||
| 63 | echo ' More information about semantic patching is available at' | ||
| 64 | echo ' http://coccinelle.lip6.fr/' | ||
| 65 | echo '' | ||
| 66 | |||
| 67 | $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1 | ||
| 68 | else | ||
| 69 | $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 | ||
| 70 | fi | ||
| 71 | |||
| 72 | } | ||
| 73 | |||
| 74 | if [ "$COCCI" = "" ] ; then | ||
| 75 | for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do | ||
| 76 | coccinelle $f | ||
| 77 | done | ||
| 78 | else | ||
| 79 | coccinelle $COCCI | ||
| 80 | fi | ||
diff --git a/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci b/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci new file mode 100644 index 000000000000..7d4771d449c3 --- /dev/null +++ b/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | /// | ||
| 2 | /// Casting (void *) value returned by kmalloc is useless | ||
| 3 | /// as mentioned in Documentation/CodingStyle, Chap 14. | ||
| 4 | /// | ||
| 5 | // Confidence: High | ||
| 6 | // Copyright: 2009,2010 Nicolas Palix, DIKU. GPLv2. | ||
| 7 | // URL: http://coccinelle.lip6.fr/ | ||
| 8 | // Options: -no_includes -include_headers | ||
| 9 | // | ||
| 10 | // Keywords: kmalloc, kzalloc, kcalloc | ||
| 11 | // Version min: < 2.6.12 kmalloc | ||
| 12 | // Version min: < 2.6.12 kcalloc | ||
| 13 | // Version min: 2.6.14 kzalloc | ||
| 14 | // | ||
| 15 | |||
| 16 | virtual context | ||
| 17 | virtual patch | ||
| 18 | virtual org | ||
| 19 | virtual report | ||
| 20 | |||
| 21 | //---------------------------------------------------------- | ||
| 22 | // For context mode | ||
| 23 | //---------------------------------------------------------- | ||
| 24 | |||
| 25 | @depends on context@ | ||
| 26 | type T; | ||
| 27 | @@ | ||
| 28 | |||
| 29 | * (T *) | ||
| 30 | \(kmalloc\|kzalloc\|kcalloc\)(...) | ||
| 31 | |||
| 32 | //---------------------------------------------------------- | ||
| 33 | // For patch mode | ||
| 34 | //---------------------------------------------------------- | ||
| 35 | |||
| 36 | @depends on patch@ | ||
| 37 | type T; | ||
| 38 | @@ | ||
| 39 | |||
| 40 | - (T *) | ||
| 41 | \(kmalloc\|kzalloc\|kcalloc\)(...) | ||
| 42 | |||
| 43 | //---------------------------------------------------------- | ||
| 44 | // For org and report mode | ||
| 45 | //---------------------------------------------------------- | ||
| 46 | |||
| 47 | @r depends on org || report@ | ||
| 48 | type T; | ||
| 49 | position p; | ||
| 50 | @@ | ||
| 51 | |||
| 52 | (T@p *)\(kmalloc\|kzalloc\|kcalloc\)(...) | ||
| 53 | |||
| 54 | @script:python depends on org@ | ||
| 55 | p << r.p; | ||
| 56 | t << r.T; | ||
| 57 | @@ | ||
| 58 | |||
| 59 | coccilib.org.print_safe_todo(p[0], t) | ||
| 60 | |||
| 61 | @script:python depends on report@ | ||
| 62 | p << r.p; | ||
| 63 | t << r.T; | ||
| 64 | @@ | ||
| 65 | |||
| 66 | msg="WARNING: casting value returned by k[cmz]alloc to (%s *) is useless." % (t) | ||
| 67 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/alloc/kzalloc-simple.cocci b/scripts/coccinelle/alloc/kzalloc-simple.cocci new file mode 100644 index 000000000000..2eae828fc657 --- /dev/null +++ b/scripts/coccinelle/alloc/kzalloc-simple.cocci | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /// | ||
| 2 | /// kzalloc should be used rather than kmalloc followed by memset 0 | ||
| 3 | /// | ||
| 4 | // Confidence: High | ||
| 5 | // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2. | ||
| 6 | // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
| 7 | // URL: http://coccinelle.lip6.fr/rules/kzalloc.html | ||
