]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scripts: coccicheck: filter *.cocci files by MODE
authorSongwei Chai <quic_songchai@quicinc.com>
Fri, 6 Jun 2025 06:09:36 +0000 (14:09 +0800)
committerJulia Lawall <Julia.Lawall@inria.fr>
Sun, 21 Dec 2025 20:04:45 +0000 (21:04 +0100)
Enhance the coccicheck script to filter *.cocci files based on the
specified MODE (e.g., report, patch). This ensures that only compatible
semantic patch files are executed, preventing errors such as:

    "virtual rule report not supported"

This error occurs when a .cocci file does not define a 'virtual <MODE>'
rule, yet is executed in that mode.

For example:

    make coccicheck M=drivers/hwtracing/coresight/ MODE=report

In this case, running "secs_to_jiffies.cocci" would trigger the error
because it lacks support for 'report' mode. With this change, such files
are skipped automatically, improving robustness and developer
experience.

Signed-off-by: Songwei Chai <quic_songchai@quicinc.com>
Reviewed-by: Julia Lawall <Julia.Lawall@inria.fr>
scripts/coccicheck

index 0e6bc5a10320c9926f3a611bf71911c102d25ea2..89d591af5f3e7bf3302f92216c59a14c49332196 100755 (executable)
@@ -270,7 +270,11 @@ fi
 
 if [ "$COCCI" = "" ] ; then
     for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
-       coccinelle $f
+        if grep -q "virtual[[:space:]]\+$MODE" "$f"; then
+                coccinelle $f
+        else
+                echo "warning: Skipping $f as it does not match mode '$MODE'"
+        fi
     done
 else
     coccinelle $COCCI