All of lore.kernel.org
 help / color / mirror / Atom feed
From: Davidson Francis <davidsondfgl@gmail.com>
To: Julia Lawall <Julia.Lawall@inria.fr>,
	Gilles Muller <Gilles.Muller@inria.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	Michal Marek <michal.lkml@markovi.net>
Cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org
Subject: Re: [Cocci] [PATCH v2] scripts: coccicheck: Fix chain mode in coccicheck
Date: Tue, 27 Apr 2021 04:14:15 -0300	[thread overview]
Message-ID: <20210427071415.GA12067@theldus> (raw)
In-Reply-To: <20210306200541.3133-1-davidsondfgl@gmail.com>

On Sat, Mar 06, 2021 at 05:05:41PM -0300, Davidson Francis wrote:
> 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'.
> 
> Signed-off-by: Davidson Francis <davidsondfgl@gmail.com>
> ---
> 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(-)
> 
> diff --git a/scripts/coccicheck b/scripts/coccicheck
> index 65fee63aeadb..165701657c5a 100755
> --- a/scripts/coccicheck
> +++ b/scripts/coccicheck
> @@ -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
>  
>  }
> -- 
> 2.29.1
> 

Ping for review.

Regards,
Davidson Francis.

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

WARNING: multiple messages have this Message-ID (diff)
From: Davidson Francis <davidsondfgl@gmail.com>
To: Julia Lawall <Julia.Lawall@inria.fr>,
	Gilles Muller <Gilles.Muller@inria.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	Michal Marek <michal.lkml@markovi.net>
Cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org,
	davidsondfgl@gmail.com
Subject: Re: [Cocci] [PATCH v2] scripts: coccicheck: Fix chain mode in coccicheck
Date: Tue, 27 Apr 2021 04:14:15 -0300	[thread overview]
Message-ID: <20210427071415.GA12067@theldus> (raw)
In-Reply-To: <20210306200541.3133-1-davidsondfgl@gmail.com>

On Sat, Mar 06, 2021 at 05:05:41PM -0300, Davidson Francis wrote:
> 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'.
> 
> Signed-off-by: Davidson Francis <davidsondfgl@gmail.com>
> ---
> 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(-)
> 
> diff --git a/scripts/coccicheck b/scripts/coccicheck
> index 65fee63aeadb..165701657c5a 100755
> --- a/scripts/coccicheck
> +++ b/scripts/coccicheck
> @@ -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
>  
>  }
> -- 
> 2.29.1
> 

Ping for review.

Regards,
Davidson Francis.


  reply	other threads:[~2021-04-27  7:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-06 20:05 [Cocci] [PATCH v2] scripts: coccicheck: Fix chain mode in coccicheck Davidson Francis
2021-03-06 20:05 ` Davidson Francis
2021-04-27  7:14 ` Davidson Francis [this message]
2021-04-27  7:14   ` [Cocci] " Davidson Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210427071415.GA12067@theldus \
    --to=davidsondfgl@gmail.com \
    --cc=Gilles.Muller@inria.fr \
    --cc=Julia.Lawall@inria.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=nicolas.palix@imag.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.