cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Denis Efremov <efremov@linux.com>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Rule for turning !unlikely to likely
Date: Sat, 24 Aug 2019 19:23:15 +0800 (CST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1908241922190.2720@hadrien> (raw)
In-Reply-To: <44525ca7-a97b-0858-9131-a97459bac4b5@linux.com>



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

  reply	other threads:[~2019-08-24 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-24  7:14 [Cocci] Rule for turning !unlikely to likely Denis Efremov
2019-08-24 11:23 ` Julia Lawall [this message]
2019-08-24 13:01   ` Denis Efremov

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=alpine.DEB.2.21.1908241922190.2720@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=efremov@linux.com \
    /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 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).