2017-11-29 21:49:05 +03:00
#!/bin/bash -e
2019-04-28 21:43:00 +03:00
# Exclude following paths from the Coccinelle transformations
EXCLUDED_PATHS = (
"src/boot/efi/*"
"src/shared/linux/*"
"src/basic/linux/*"
# Symlinked to test-bus-vtable-cc.cc, which causes issues with the IN_SET macro
"src/libsystemd/sd-bus/test-bus-vtable.c"
2021-03-18 13:59:53 +03:00
"src/libsystemd/sd-journal/lookup3.c"
2019-04-28 21:43:00 +03:00
)
2018-06-07 16:07:14 +03:00
top = " $( git rev-parse --show-toplevel) "
2018-04-20 16:21:06 +03:00
args =
2019-04-28 21:43:00 +03:00
# Create an array from files tracked by git...
mapfile -t files < <( git ls-files ':/*.[ch]' )
# ...and filter everything that matches patterns from EXCLUDED_PATHS
for excl in " ${ EXCLUDED_PATHS [@] } " ; do
files = ( ${ files [@]// $excl } )
done
2018-04-20 16:21:06 +03:00
case " $1 " in
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
-i)
args = " $args --in-place "
shift
; ;
2018-04-20 16:21:06 +03:00
esac
2018-04-20 16:07:42 +03:00
2018-06-11 16:58:09 +03:00
if ! parallel -h >/dev/null; then
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
echo 'Please install GNU parallel (package "parallel")'
exit 1
2018-06-11 16:58:09 +03:00
fi
2020-10-07 16:24:39 +03:00
for SCRIPT in ${ @- $top /coccinelle/*.cocci } ; do
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
echo " --x-- Processing $SCRIPT --x-- "
TMPFILE = ` mktemp`
echo " + spatch --sp-file $SCRIPT $args ... "
parallel --halt now,fail= 1 --keep-order --noswap --max-args= 20 \
2020-10-07 16:24:39 +03:00
spatch --macro-file= " $top /coccinelle/macros.h " --sp-file $SCRIPT $args ::: " ${ files [@] } " \
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
2>" $TMPFILE " || cat " $TMPFILE "
echo -e " --x-- Processed $SCRIPT --x--\n "
2017-11-29 21:49:05 +03:00
done