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)
# 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="$!"
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
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
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
}
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"
run_smatch=
run_cppcheck=
run_coccinelle=
+cocci_path=
check_only=
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")"
--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
}
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"
smatch=
cppcheck=
coccinelle=
+cocci_path=
check_only=
check=0
kmake_opts=
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")"