diff options
Diffstat (limited to 'src/spdk/dpdk/devtools/cocci.sh')
-rwxr-xr-x | src/spdk/dpdk/devtools/cocci.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/spdk/dpdk/devtools/cocci.sh b/src/spdk/dpdk/devtools/cocci.sh new file mode 100755 index 000000000..ab9a6efe9 --- /dev/null +++ b/src/spdk/dpdk/devtools/cocci.sh @@ -0,0 +1,36 @@ +#! /bin/sh +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2015-2020 Mellanox Technologies, Ltd + +# Apply coccinelle transforms. + +SRCTREE=$(readlink -f $(dirname $0)/..) +COCCI=$SRCTREE/devtools/cocci +[ -n "$SPATCH" ] || SPATCH=$(which spatch) + +PATCH_LIST="$@" +[ -n "$PATCH_LIST" ] || PATCH_LIST=$(echo $COCCI/*.cocci) + +[ -x "$SPATCH" ] || ( + echo "Coccinelle tools not installed." + exit 1 +) + +tmp=$(mktemp -t dpdk.cocci.XXX) + +for c in $PATCH_LIST; do + while true; do + echo -n "Applying $c..." + $SPATCH --sp-file $c -c --linux-spacing --very-quiet \ + --include-headers --preprocess \ + --in-place --dir $SRCTREE > $tmp + if [ -s $tmp ]; then + echo " changes applied, retrying." + else + echo " no change." + break; + fi + done +done + +rm -f $tmp |