scripts: coccicheck: filter *.cocci files by MODE

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>

authored by Songwei Chai and committed by Julia Lawall 3766511d 9094662f

Changed files
+5 -1
scripts
+5 -1
scripts/coccicheck
··· 270 270 271 271 if [ "$COCCI" = "" ] ; then 272 272 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do 273 - coccinelle $f 273 + if grep -q "virtual[[:space:]]\+$MODE" "$f"; then 274 + coccinelle $f 275 + else 276 + echo "warning: Skipping $f as it does not match mode '$MODE'" 277 + fi 274 278 done 275 279 else 276 280 coccinelle $COCCI