linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] scripts: coccicheck: filter *.cocci files by MODE
@ 2025-06-05  4:44 Songwei Chai
  2025-06-05 17:43 ` Nicolas Palix
  0 siblings, 1 reply; 3+ messages in thread
From: Songwei Chai @ 2025-06-05  4:44 UTC (permalink / raw)
  To: Julia Lawall, Nicolas Palix, cocci
  Cc: linux-kernel, quic_songchai, quic_tingweiz, quic_jinlmao

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>
---
 scripts/coccicheck | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/coccicheck b/scripts/coccicheck
index 0e6bc5a10320..18a69edcea66 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -270,7 +270,9 @@ 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
+        fi
     done
 else
     coccinelle $COCCI


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] scripts: coccicheck: filter *.cocci files by MODE
  2025-06-05  4:44 [PATCH v1] scripts: coccicheck: filter *.cocci files by MODE Songwei Chai
@ 2025-06-05 17:43 ` Nicolas Palix
  2025-06-06  5:33   ` Songwei Chai
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Palix @ 2025-06-05 17:43 UTC (permalink / raw)
  To: Songwei Chai, Julia Lawall, cocci
  Cc: linux-kernel, quic_tingweiz, quic_jinlmao

Hi Songwei,

Le 05/06/2025 à 06:44, Songwei Chai a écrit :
> 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.

I am fine with the idea even if the orignal idea was to be exhaustive in 
the implementation of the mode in each SP.

However, silently discarding the patch is maybe not what one would 
expect as the considered SP will vary according to the mode.

Hence, could I suggest to add an else branch reporting a warning at least ?

Regards,

> 
> 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>
> ---
>   scripts/coccicheck | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/coccicheck b/scripts/coccicheck
> index 0e6bc5a10320..18a69edcea66 100755
> --- a/scripts/coccicheck
> +++ b/scripts/coccicheck
> @@ -270,7 +270,9 @@ 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
> +        fi
>       done
>   else
>       coccinelle $COCCI
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] scripts: coccicheck: filter *.cocci files by MODE
  2025-06-05 17:43 ` Nicolas Palix
@ 2025-06-06  5:33   ` Songwei Chai
  0 siblings, 0 replies; 3+ messages in thread
From: Songwei Chai @ 2025-06-06  5:33 UTC (permalink / raw)
  To: Nicolas Palix, Julia Lawall, cocci
  Cc: linux-kernel, quic_tingweiz, quic_jinlmao


On 6/6/2025 1:43 AM, Nicolas Palix wrote:
> Hi Songwei,
>
> Le 05/06/2025 à 06:44, Songwei Chai a écrit :
>> 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.
>
> I am fine with the idea even if the orignal idea was to be exhaustive 
> in the implementation of the mode in each SP.
>
> However, silently discarding the patch is maybe not what one would 
> expect as the considered SP will vary according to the mode.
>
> Hence, could I suggest to add an else branch reporting a warning at 
> least ?
>
> Regards,
Sure, will update patch with else branch reporting a warning.
>
>>
>> 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>
>> ---
>>   scripts/coccicheck | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/coccicheck b/scripts/coccicheck
>> index 0e6bc5a10320..18a69edcea66 100755
>> --- a/scripts/coccicheck
>> +++ b/scripts/coccicheck
>> @@ -270,7 +270,9 @@ 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
>> +        fi
>>       done
>>   else
>>       coccinelle $COCCI
>>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-06  5:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05  4:44 [PATCH v1] scripts: coccicheck: filter *.cocci files by MODE Songwei Chai
2025-06-05 17:43 ` Nicolas Palix
2025-06-06  5:33   ` Songwei Chai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).