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"
)
2018-06-07 16:07:14 +03:00
top = " $( git rev-parse --show-toplevel) "
coccinelle: add explicit statement isomorphisms
Coccinelle needs a custom isomorphism file with rules (isomorphisms) how
to correctly rewrite conditions with explicit NULL checks (i.e.
if (ptr == NULL)) to their shorter form (i.e. if (!ptr)). Coccinelle
already contains such isomorphisms in its default .iso file, however,
they're in the opposite direction, which results in useless output from
coccinelle/equals-null.cocci.
With this fix, `spatch` should no longer report patches like:
@@ -628,8 +628,9 @@ static int path_deserialize_item(Unit *u
f = path_result_from_string(value);
if (f < 0)
log_unit_debug(u, "Failed to parse result value: %s", value);
- else if (f != PATH_SUCCESS)
- p->result = f;
+ else {if (f != PATH_SUCCESS)
+ p->result = f;
+ }
} else
log_unit_debug(u, "Unknown serialization key: %s", key);
2019-04-26 22:42:16 +03:00
iso_defs = " $top /coccinelle/systemd-definitions.iso "
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
2018-06-07 16:07:14 +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 \
2019-04-28 21:43:00 +03:00
spatch --iso-file $iso_defs --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