[PATCH 08/11] Start using cocci scripts from the kernel tree
Artem Bityutskiy
dedekind1 at gmail.com
Fri Feb 7 07:28:21 PST 2014
From: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
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 at linux.intel.com>
---
aiaiai-test-patchset | 13 +++++++++----
doc/TODO.txt | 3 ---
helpers/aiaiai-checker | 21 +++++++++++++++------
helpers/aiaiai-make-kernel | 11 ++++++++---
4 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/aiaiai-test-patchset b/aiaiai-test-patchset
index bda85b3..b9610bb 100755
--- a/aiaiai-test-patchset
+++ b/aiaiai-test-patchset
@@ -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,19 @@ 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
+mkdir -p $verbose "$tmpdir/coccinelle" >&2
+git archive "$commit_id1" scripts/coccinelle | \
+ tar $verbose --strip-components=2 -C "$tmpdir/coccinelle" -x
+coccinelle="--coccinelle=$tmpdir/coccinelle"
+
# Run checkpatch.pl in backgound.
test_checkpatch &
pid_checkpatch="$!"
diff --git a/doc/TODO.txt b/doc/TODO.txt
index e64901c..adc9a97 100644
--- a/doc/TODO.txt
+++ b/doc/TODO.txt
@@ -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
diff --git a/helpers/aiaiai-checker b/helpers/aiaiai-checker
index 21d52ef..b3f7274 100755
--- a/helpers/aiaiai-checker
+++ b/helpers/aiaiai-checker
@@ -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")"
diff --git a/helpers/aiaiai-make-kernel b/helpers/aiaiai-make-kernel
index 4db126b..5604f6c 100755
--- a/helpers/aiaiai-make-kernel
+++ b/helpers/aiaiai-make-kernel
@@ -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")"
--
1.8.5.2
More information about the aiaiai
mailing list