Le 15/03/2013 16:14, Nicolas Palix a écrit :
> Alternatively, you could use 'make coccicheck MODE=report' as every
> cocci file currently provide at least this mode

Yes that works thanks.

> or we could swap patch and report for the chain mode.

[...]

> One may improve the handling of the chain mode, and skip unavailable
> modes instead of falling back to the next one in case of error...
>
> Do you volunteer ?
>

If it's just a matter of adding grep before run_cmd, the attached patch
seems to work.

But I don't have enough knowledge about all this to decide what's the
best thing to do among everything you said above.

Brice
 
coccicheck: check if a mode is supported before running it during chain

The chain mode tries patch, report, context and org modes until
it finds one that is supported. It causes 18 messages
  "virtual rule patch not supported"
per compiled file (since 18 of the current 42 coccichecks support
"report" without "patch").

Those messages are harmless but most users have no idea about this.
Remove them by only trying a mode if the rule supports it.

Signed-off-by: Brice Goglin <[email protected]>
Cc: Nicolas Palix <[email protected]>
Cc: Julia Lawall <[email protected]>

diff --git a/scripts/coccicheck b/scripts/coccicheck
index 85d3189..0858376 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -108,14 +108,18 @@ coccinelle () {
     fi
 
     if [ "$MODE" = "chain" ] ; then
-	run_cmd $SPATCH -D patch   \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS               || \
-	run_cmd $SPATCH -D report  \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \
-	run_cmd $SPATCH -D context \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS               || \
-	run_cmd $SPATCH -D org     \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1
+	( grep '^virtual patch$' $COCCI \
+	     && run_cmd $SPATCH -D patch   \
+			$FLAGS -sp_file $COCCI $OPT $OPTIONS               ) || \
+	( grep '^virtual report$' $COCCI \
+	     && run_cmd $SPATCH -D report  \
+			$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff ) || \
+	( grep '^virtual context$' $COCCI \
+	     && run_cmd $SPATCH -D context \
+			$FLAGS -sp_file $COCCI $OPT $OPTIONS               ) || \
+	( grep '^virtual org$' $COCCI \
+	     && run_cmd $SPATCH -D org     \
+			$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff ) || exit 1
     elif [ "$MODE" = "rep+ctxt" ] ; then
 	run_cmd $SPATCH -D report  \
 		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to