2021-12-12 22:27:04 +03:00
#!/usr/bin/env bash
2021-10-01 13:10:22 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2021-12-12 22:27:04 +03:00
set -e
2017-11-29 21:49:05 +03:00
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
)
2021-09-29 20:55:24 +03:00
TOP_DIR = " $( git rev-parse --show-toplevel) "
ARGS = ( )
2018-04-20 16:21:06 +03:00
2019-04-28 21:43:00 +03:00
# Create an array from files tracked by git...
2021-09-29 20:55:24 +03:00
mapfile -t FILES < <( git ls-files ':/*.[ch]' )
2019-04-28 21:43:00 +03:00
# ...and filter everything that matches patterns from EXCLUDED_PATHS
for excl in " ${ EXCLUDED_PATHS [@] } " ; do
2021-09-29 20:55:24 +03:00
# shellcheck disable=SC2206
FILES = ( ${ FILES [@]// $excl } )
2019-04-28 21:43:00 +03:00
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)
2021-09-29 20:55:24 +03:00
ARGS += ( --in-place)
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
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
2021-09-29 20:55:24 +03:00
[ [ ${# @ } -ne 0 ] ] && SCRIPTS = ( " $@ " ) || SCRIPTS = ( " $TOP_DIR " /coccinelle/*.cocci)
for script in " ${ SCRIPTS [@] } " ; do
echo " --x-- Processing $script --x-- "
TMPFILE = " $( mktemp) "
echo " + spatch --sp-file $script ${ ARGS [*] } ... "
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
parallel --halt now,fail= 1 --keep-order --noswap --max-args= 20 \
2023-03-18 15:52:28 +03:00
spatch --macro-file= " $TOP_DIR /coccinelle/macros.h " --smpl-spacing --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 "
2021-09-29 20:55:24 +03:00
echo -e " --x-- Processed $script --x--\n "
2017-11-29 21:49:05 +03:00
done