scripts: coccicheck: Fix chain mode in coccicheck
PATCH v2 1/1 scripts: coccicheck: Fix chain mode in coccicheck
As described in the Coccinelle documentation (Documentation/dev-tools/ coccinelle.rst), chain mode should try patch, report, context, and org modes until one of them succeed.
It turns out that currently, the 'run_cmd_parmap' function, by failing to run $SPATCH, rather than returning an error code, kills the execution of the script by executing the exit command, rather than returning the error code.
This way, when running coccicheck in chain mode, as in:
$ make coccicheck MODE=chain
the first .cocci file that does not support one of the virtual rules stops the execution of the makefile, rather than trying the remaining rules as specified in the documentation.
Therefore, modify the coccicheck script to return the error code, rather than terminating the script. When returning the error code, it returns the same value obtained in run_cmd, instead of the generic value '1'.
---
Changes in v2:
* Use the same return value from run_cmd as the exit value
scripts/coccicheck | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/coccicheck +4 -4
@@ -153,7 +153,7 @@ run_cmd_parmap() { err=$? if [[ $err -ne 0 ]]; then echo "coccicheck failed" - exit $err + return $err fi }
@@ -251,14 +251,14 @@ coccinelle () { run_cmd $SPATCH -D context \ $FLAGS --cocci-file $COCCI $OPT $OPTIONS || \ run_cmd $SPATCH -D org \ - $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || exit 1 + $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || exit $? elif [ "$MODE" = "rep+ctxt" ] ; then run_cmd $SPATCH -D report \ $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff && \ run_cmd $SPATCH -D context \ - $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1 + $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit $? else - run_cmd $SPATCH -D $MODE $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1 + run_cmd $SPATCH -D $MODE $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit $? fi }
Signature · 1 line
2.29.1
Quoted 63 lines · Davidson Francis
As described in the Coccinelle documentation (
Documentation/dev-tools/coccinelle.rst), chain mode should try patch, report, context, and org modes until one of them succeed.It turns out that currently, the '
run_cmd_parmap' function, by failing to run $SPATCH, rather than returning an error code, kills the execution of the script by executing the exit command, rather than returning the error code.This way, when running coccicheck in chain mode, as in:
$ make coccicheck MODE=chainthe first .cocci file that does not support one of the virtual rules stops the execution of the makefile, rather than trying the remaining rules as specified in the documentation.
Therefore, modify the coccicheck script to return the error code, rather than terminating the script. When returning the error code, it returns the same value obtained in
run_cmd, instead of the generic value '1'.Signed-off-by Davidson Francis <[email protected]>---
Changes in v2:
* Use the same return value fromrun_cmdas the exit valuescripts/coccicheck | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)scripts/coccicheck +4
-4@@ -153,7 +153,7 @@ run_cmd_parmap() { err=$? if [[ $err -ne 0 ]]; then echo "coccicheck failed" - exit $err + return $err fi }@@ -251,14 +251,14 @@ coccinelle () { run_cmd $SPATCH -D context \ $FLAGS --cocci-file $COCCI $OPT $OPTIONS || \ run_cmd $SPATCH -D org \ - $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || exit 1 + $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || exit $? elif [ "$MODE" = "rep+ctxt" ] ; then run_cmd $SPATCH -D report \ $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff && \ run_cmd $SPATCH -D context \ - $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1 + $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit $? else - run_cmd $SPATCH -D $MODE $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1 + run_cmd $SPATCH -D $MODE $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit $? fi }Signature · 1 line
2.29.1
Ping for review.
Regards,
Davidson Francis.