Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] Rule for turning !unlikely to likely
@ 2019-08-24  7:14 Denis Efremov
  2019-08-24 11:23 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Denis Efremov @ 2019-08-24  7:14 UTC (permalink / raw)
  To: cocci

Hi,

I'm trying to write a rule for turning !unlikely to likely and vice versa.
However, it's hard for me to understand what is wrong with the rule and how to
make it work. Any suggestions? Do I need to introduce 'expression E;' instead
'(...)'? BTW, spatch hangs with -Dorg.

The rule:

virtual patch
virtual context
virtual org
virtual report

//----------------------------------------------------------
//  For context mode
//----------------------------------------------------------

@depends on context disable unlikely@
@@

(
* !likely(...)
|
* !unlikely(...)
)

//----------------------------------------------------------
//  For patch mode
//----------------------------------------------------------

@depends on patch disable unlikely@
@@

(
-!likely
+unlikely
 (...)
|
-!unlikely
+likely
 (...)
)

//----------------------------------------------------------
//  For org and report mode
//----------------------------------------------------------

@r depends on (org || report) disable unlikely@
position p;
@@

(
 !likely@p(...)
|
 !unlikely@p(...)
)

@script:python depends on org@
p << r.p;
@@

coccilib.org.print_todo(p[0], "WARNING use unlikely instead of !likely")

@script:python depends on report@
p << r.p;
@@

msg="WARNING: Use unlikely instead of !likely and likely instead of !unlikely"
coccilib.report.print_report(p[0], msg)

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

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

* Re: [Cocci] Rule for turning !unlikely to likely
  2019-08-24  7:14 [Cocci] Rule for turning !unlikely to likely Denis Efremov
@ 2019-08-24 11:23 ` Julia Lawall
  2019-08-24 13:01   ` Denis Efremov
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2019-08-24 11:23 UTC (permalink / raw)
  To: Denis Efremov; +Cc: cocci



On Sat, 24 Aug 2019, Denis Efremov wrote:

> Hi,
>
> I'm trying to write a rule for turning !unlikely to likely and vice versa.
> However, it's hard for me to understand what is wrong with the rule and how to
> make it work. Any suggestions? Do I need to introduce 'expression E;' instead
> '(...)'? BTW, spatch hangs with -Dorg.

Try adding

disable unlikely

to each rule.  There is an isomorphism that makes likely and unlikely
optional and perhaps it causes problems.

julia

>
> The rule:
>
> virtual patch
> virtual context
> virtual org
> virtual report
>
> //----------------------------------------------------------
> //  For context mode
> //----------------------------------------------------------
>
> @depends on context disable unlikely@
> @@
>
> (
> * !likely(...)
> |
> * !unlikely(...)
> )
>
> //----------------------------------------------------------
> //  For patch mode
> //----------------------------------------------------------
>
> @depends on patch disable unlikely@
> @@
>
> (
> -!likely
> +unlikely
>  (...)
> |
> -!unlikely
> +likely
>  (...)
> )
>
> //----------------------------------------------------------
> //  For org and report mode
> //----------------------------------------------------------
>
> @r depends on (org || report) disable unlikely@
> position p;
> @@
>
> (
>  !likely@p(...)
> |
>  !unlikely@p(...)
> )
>
> @script:python depends on org@
> p << r.p;
> @@
>
> coccilib.org.print_todo(p[0], "WARNING use unlikely instead of !likely")
>
> @script:python depends on report@
> p << r.p;
> @@
>
> msg="WARNING: Use unlikely instead of !likely and likely instead of !unlikely"
> coccilib.report.print_report(p[0], msg)
>
> Thanks,
> Denis
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Rule for turning !unlikely to likely
  2019-08-24 11:23 ` Julia Lawall
@ 2019-08-24 13:01   ` Denis Efremov
  0 siblings, 0 replies; 3+ messages in thread
From: Denis Efremov @ 2019-08-24 13:01 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

On 24.08.2019 14:23, Julia Lawall wrote:
> 
> 
> On Sat, 24 Aug 2019, Denis Efremov wrote:
> 
>> Hi,
>>
>> I'm trying to write a rule for turning !unlikely to likely and vice versa.
>> However, it's hard for me to understand what is wrong with the rule and how to
>> make it work. Any suggestions? Do I need to introduce 'expression E;' instead
>> '(...)'? BTW, spatch hangs with -Dorg.
> 
> Try adding
> 
> disable unlikely
> 
> to each rule.  There is an isomorphism that makes likely and unlikely
> optional and perhaps it causes problems.

It's already added, as you could see it in the listing. :) Maybe I do it in the
wrong order?

@depends on context disable unlikely@
@depends on patch disable unlikely@
@r depends on (org || report) disable unlikely@

> 
> julia
> 
>>
>> The rule:
>>
>> virtual patch
>> virtual context
>> virtual org
>> virtual report
>>
>> //----------------------------------------------------------
>> //  For context mode
>> //----------------------------------------------------------
>>
>> @depends on context disable unlikely@
>> @@
>>
>> (
>> * !likely(...)
>> |
>> * !unlikely(...)
>> )
>>
>> //----------------------------------------------------------
>> //  For patch mode
>> //----------------------------------------------------------
>>
>> @depends on patch disable unlikely@
>> @@
>>
>> (
>> -!likely
>> +unlikely
>>  (...)
>> |
>> -!unlikely
>> +likely
>>  (...)
>> )
>>
>> //----------------------------------------------------------
>> //  For org and report mode
>> //----------------------------------------------------------
>>
>> @r depends on (org || report) disable unlikely@
>> position p;
>> @@
>>
>> (
>>  !likely@p(...)
>> |
>>  !unlikely@p(...)
>> )
>>
>> @script:python depends on org@
>> p << r.p;
>> @@
>>
>> coccilib.org.print_todo(p[0], "WARNING use unlikely instead of !likely")
>>
>> @script:python depends on report@
>> p << r.p;
>> @@
>>
>> msg="WARNING: Use unlikely instead of !likely and likely instead of !unlikely"
>> coccilib.report.print_report(p[0], msg)
>>
>> Thanks,
>> Denis
>> _______________________________________________
>> Cocci mailing list
>> Cocci@systeme.lip6.fr
>> https://systeme.lip6.fr/mailman/listinfo/cocci
>>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-24  7:14 [Cocci] Rule for turning !unlikely to likely Denis Efremov
2019-08-24 11:23 ` Julia Lawall
2019-08-24 13:01   ` Denis Efremov

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr cocci@archiver.kernel.org
	public-inbox-index cocci


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox