]> www.infradead.org Git - users/dedekind/aiaiai.git/commitdiff
Start using cocci scripts from the kernel tree
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 7 Feb 2014 15:04:26 +0000 (17:04 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Mon, 10 Feb 2014 07:53:06 +0000 (09:53 +0200)
Start using coccinelle scripts from the kernel tree we build against. This is
better than carrying our own copies of coccinelle scripts, since they tend to
become out-of-date.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
aiaiai-test-patchset
doc/TODO.txt
helpers/aiaiai-checker
helpers/aiaiai-make-kernel

index bda85b35bdf9776d682c5856ae63125496998023..e936265a8c194d6473be9a482d27082ffd630fe8 100755 (executable)
@@ -308,7 +308,7 @@ while true; do
                program_required "cppcheck" "Usually Linux distribution provide a cppcheck package"
                ;;
        --coccinelle)
-               coccinelle="--coccinelle"
+               coccinelle="yes"
                program_required "spatch" "Usually Linux distribution provide a 'spatch' or 'coccinelle' package"
                ;;
        -K|--keywords)
@@ -413,14 +413,21 @@ git diff -U0 -M "$commit_id1".."$commit_id2" > "$tmpdir/diff-for-diff-log"
 # Generate a diff for checkpatch.pl
 git diff -M "$commit_id1".."$commit_id2" > "$tmpdir/diff-for-checkpatch"
 
-# Make a copy of 'checlpatch.pl'. This is safer than using it directly from the
-# git tree because we'll apply patches under test there, and the patches may
-# also change 'checlpatch.pl'.
+# Make a copy of 'checlpatch.pl' and coccinelle scripts. This is safer than
+# using them directly from the git tree because we'll apply patches under test
+# there, and the patches may also change 'checlpatch.pl' or coccinelle scripts.
 mkdir -p $verbose "$tmpdir/checkpatch" >&2
 checkpatch_pl="$tmpdir/checkpatch/checkpatch.pl"
 git show "$commit_id1:scripts/checkpatch.pl" > "$checkpatch_pl"
 chmod $verbose u+x "$checkpatch_pl" >&2
 
+if [ -n "$coccinelle" ]; then
+       mkdir -p $verbose "$tmpdir/coccinelle" >&2
+       git archive "$commit_id1" scripts/coccinelle | \
+               tar $verbose --strip-components=2 -C "$tmpdir/coccinelle" -x >&2
+       coccinelle="--coccinelle=$tmpdir/coccinelle"
+fi
+
 # Run checkpatch.pl in backgound.
 test_checkpatch &
 pid_checkpatch="$!"
index e64901c8c7a1673f5fd053a6efc12a590a51ba51..adc9a97298b6e6e894f1eb3ad768ff49fcebea07 100644 (file)
@@ -46,9 +46,6 @@ implementing them.
       int found;
           ^
     Aiaiai does not process them correctly which leads to ugly diffs. Fix this.
-  * Stop carrying own copy of coccinelle. Just use the ones from the
-    project kernel tree. This is better because our own copy tend to get
-    out-of-date.
   * We hard-code 'KCFLAGS='-Wno-missing-field-initializers
     -Wno-sign-compare' and W=1 in 'aiaiai-make-kernel'. This is not that
     nice. It is better to make these things to be the default value of
index 21d52ef536c1459824b2c0d2ec88a2b7a805e71a..b3f72748ebc046aae1a81ecf37d349baa703eea1 100755 (executable)
@@ -27,17 +27,19 @@ show_usage()
        cat <<-EOF
 Usage: $PROG [options] -- ...
 
-This is an internal aiaiai helper program which runs various source code
-analysis tools when building the kernel. Options for $PROG has to go first,
+This is an internal Aiaiai helper program which runs various source code
+analysis tools when building the kernel. Options for "$PROG" has to go first,
 then there has to be a "--" delimiter, and then any number of options which are
 not interpreted by this script but passed further to the code analysis tool
-(sparse or smatch).
+(sparse, smatch, etc).
 
 Options:
       --sparse           check with sparse;
       --smatch           check with smatch;
       --cppcheck         check with cppcheck;
-      --coccinelle       check with coccinelle (spatch);
+      --coccinelle=PATH  check with coccinelle (spatch) using coccinelle
+                         scripts from PATH; the scripts have to have ".cocci"
+                         extention and may reside anywhere under PATH
       --check-only=FILE  check only files listed in FILE;
   -h, --help             show this text and exit.
 EOF
@@ -64,7 +66,11 @@ run_coccinelle()
        local spatch spatches flags pid
        local pids=
 
-       spatches="$(find $srcdir -name '*.cocci')"
+       spatches="$(find "$cocci_path" -name '*.cocci')"
+       if [ -z "$spatches" ]; then
+               die "no coccinelle scripts (*.cocci) found in \"$cocci_path\""
+       fi
+
        for spatch in $spatches; do
                # Coccinelle is not stable enough so far and dies because of
                # internal issues sometimes or just never stops. So we specify
@@ -97,7 +103,7 @@ cleanup_handler()
 }
 set_cleanup_handler cleanup_handler
 
-TEMP=`getopt -n $PROG -o h --long sparse,smatch,cppcheck,coccinelle,check-only:,help -- "$@"` ||
+TEMP=`getopt -n $PROG -o h --long sparse,smatch,cppcheck,coccinelle:,check-only:,help -- "$@"` ||
        fail_usage ""
 eval set -- "$TEMP"
 
@@ -107,6 +113,7 @@ run_sparse=
 run_smatch=
 run_cppcheck=
 run_coccinelle=
+cocci_path=
 check_only=
 
 while true; do
@@ -125,7 +132,9 @@ while true; do
                ;;
        --coccinelle)
                run_coccinelle=1
+               cocci_path="$(opt_check_dir "$1" "$2")"
                program_required "spatch" "Usually Linux distribution provide a 'spatch' or 'coccinelle' package"
+               shift
                ;;
        --check-only)
                check_only="$(opt_check_read "$1" "$2")"
index 4db126bf09ad83e1e5b62e86dd0cdb0664dba9c0..5604f6c9a2e768c699033f8384eea191bdbb1d6c 100755 (executable)
@@ -52,7 +52,9 @@ Options:
       --sparse           check with sparse while building;
       --smatch           check with smatch while building;
       --cppcheck         check with cppcheck while building;
-      --coccinelle       check with coccinelle (spatch) while building;
+      --coccinelle=PATH  check with coccinelle (spatch) using coccinelle
+                         scripts from PATH; the scripts have to have ".cocci"
+                         extention and may reside anywhere under PATH
       --check-only=FILE  check only files listed in FILE;
   -M, --kmake-opts       additional options to append to the final kernel
                          compilation 'make' command
@@ -136,7 +138,7 @@ cleanup_handler()
 }
 set_cleanup_handler cleanup_handler
 
-TEMP=`getopt -n $PROG -o o:,D:,j:,O:,E:,k:,a:,M:,v,h --long objdir:,defconfig:,jobs:,stdout:,stderr:,keep-going,arch:,sparse,smatch,cppcheck,coccinelle,check-only:,kmake-opts:,verbose,help -- "$@"` ||
+TEMP=`getopt -n $PROG -o o:,D:,j:,O:,E:,k:,a:,M:,v,h --long objdir:,defconfig:,jobs:,stdout:,stderr:,keep-going,arch:,sparse,smatch,cppcheck,coccinelle:,check-only:,kmake-opts:,verbose,help -- "$@"` ||
        fail_usage ""
 eval set -- "$TEMP"
 
@@ -150,6 +152,7 @@ sparse=
 smatch=
 cppcheck=
 coccinelle=
+cocci_path=
 check_only=
 check=0
 kmake_opts=
@@ -203,8 +206,10 @@ while true; do
                check=1
                ;;
        --coccinelle)
-               coccinelle="--coccinelle"
+               cocci_path="$(opt_check_dir "$1" "$2")"
+               coccinelle="--coccinelle=$cocci_path"
                check=1
+               shift
                ;;
        --check-only)
                check_only="--check-only $(opt_check_read "$1" "$2")"