mirror of
https://github.com/systemd/systemd
synced 2024-10-07 00:30:59 +00:00
b3fd7b53ff
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);
29 lines
742 B
Bash
Executable file
29 lines
742 B
Bash
Executable file
#!/bin/bash -e
|
|
|
|
top="$(git rev-parse --show-toplevel)"
|
|
files="$(git ls-files ':/*.[ch]')"
|
|
iso_defs="$top/coccinelle/systemd-definitions.iso"
|
|
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 --iso-file $iso_defs --sp-file $SCRIPT $args ::: $files \
|
|
2>"$TMPFILE" || cat "$TMPFILE"
|
|
echo -e "--x-- Processed $SCRIPT --x--\n"
|
|
done
|