summaryrefslogtreecommitdiffstats
path: root/coccinelle/run-coccinelle.sh
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2023-12-26 00:41:40 +0100
committerFrantisek Sumsal <frantisek@sumsal.cz>2023-12-26 11:23:19 +0100
commit4d3510d00fb978c101912b6873746bf3f43ca5e1 (patch)
treebaaa244eabf6f15f11688c84a28a647c76c69c77 /coccinelle/run-coccinelle.sh
parentMerge pull request #30633 from mrc0mmand/cocci-shenanigans (diff)
downloadsystemd-4d3510d00fb978c101912b6873746bf3f43ca5e1.tar.xz
systemd-4d3510d00fb978c101912b6873746bf3f43ca5e1.zip
coccinelle: explicitly undefine SD_BOOT
So Coccinelle doesn't pull in includes guarded by #if SD_BOOT. For example: $ head -n5 main.c #if FOO #include "foo.h" #else #include "bar.h" #endif $ spatch --verbose-includes --recursive-includes --sp-file zz-drop-braces.cocci main.c init_defs_builtins: /usr/lib64/coccinelle/standard.h HANDLING: main.c including ./foo.h including ./bar.h $ spatch --verbose-includes --recursive-includes --sp-file zz-drop-braces.cocci main.c --undefined FOO init_defs_builtins: /usr/lib64/coccinelle/standard.h HANDLING: main.c including ./bar.h
Diffstat (limited to 'coccinelle/run-coccinelle.sh')
-rwxr-xr-xcoccinelle/run-coccinelle.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh
index bb72a493f0..360f9268e5 100755
--- a/coccinelle/run-coccinelle.sh
+++ b/coccinelle/run-coccinelle.sh
@@ -7,7 +7,6 @@ set -e
# that TEST(xsetxattr) yields test_xsetxattr() and uses just xsetxattr() in this case, which then conflicts
# with the tested xsetxattr() function, leading up to the whole test case getting skipped due to
# conflicting typedefs
-# - something keeps pulling in src/boot/efi/*.h stuff, even though it's excluded
# - Coccinelle has issues with some of our more complex macros
# Exclude following paths from the Coccinelle transformations
@@ -73,7 +72,9 @@ for script in "${SCRIPTS[@]}"; do
# definitions (--include-headers-for-types) - otherwise we'd start formating them as well, which might be
# unwanted, especially for includes we fetch verbatim from third-parties
#
- # 4) Use cache, since generating the full AST is _very_ expensive, i.e. the uncached run takes 15 - 30
+ # 4) Explicitly undefine the SD_BOOT symbol, so Coccinelle ignores includes guarded by #if SD_BOOT
+ #
+ # 5) Use cache, since generating the full AST is _very_ expensive, i.e. the uncached run takes 15 - 30
# minutes (for one rule(!)), vs 30 - 90 seconds when the cache is populated. One major downside of the
# cache is that it's quite big - ATTOW the cache takes around 15 GiB, but the performance boost is
# definitely worth it
@@ -82,6 +83,7 @@ for script in "${SCRIPTS[@]}"; do
-I src \
--recursive-includes \
--include-headers-for-types \
+ --undefined SD_BOOT \
--smpl-spacing \
--sp-file "$script" \
"${ARGS[@]}" ::: "${FILES[@]}" \