From: Christian Brauner Date: Fri, 8 Feb 2019 22:56:51 +0000 (+0100) Subject: coccinelle: add coccinelle support X-Git-Tag: lxc-3.2.0~159^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99dc3a338d0e7f83fae59593c9f38c6b7fec9cac;p=thirdparty%2Flxc.git coccinelle: add coccinelle support Signed-off-by: Christian Brauner --- diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh new file mode 100755 index 000000000..22ab66d3d --- /dev/null +++ b/coccinelle/run-coccinelle.sh @@ -0,0 +1,27 @@ +#!/bin/bash -e + +top="$(git rev-parse --show-toplevel)" +files="$(git ls-files ':/*.[ch]')" +args= + +case "$1" in + -i) + args="$args --in-place" + shift + ;; +esac + +if ! parallel -h >/dev/null; then + echo 'Please install GNU parallel (package "parallel")' + exit 1 +fi + +for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do + echo "--x-- Processing $SCRIPT --x--" + TMPFILE=`mktemp` + echo "+ spatch --sp-file $SCRIPT $args ..." + parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \ + spatch --sp-file $SCRIPT $args ::: $files \ + 2>"$TMPFILE" || cat "$TMPFILE" + echo -e "--x-- Processed $SCRIPT --x--\n" +done