All of lore.kernel.org
 help / color / mirror / Atom feed
From: wsa@the-dreams.de (Wolfram Sang)
To: cocci@systeme.lip6.fr
Subject: [Cocci] isomorphism with unlikely
Date: Mon, 20 May 2013 19:34:06 +0200	[thread overview]
Message-ID: <20130520173406.GB5890@katana> (raw)

Hi,

using 1.0-rc16 from debian, I use the following semantic patch:

@@
expression r, p, n;
@@
	r = platform_get_resource(p, IORESOURCE_MEM, n);
	...
(
-	if (!r) { ... }
|
-	if (unlikely(!r)) { ... }
|
-	if (unlikely(r == NULL)) { ... }
)

and running against the latest kernel tree (~3.10-rc1):

spatch --sp-file unlikely_iso.cocci ~/Kernel/linux/drivers/net/ethernet/renesas/sh_eth.c

gives me a match:

-	if (unlikely(res == NULL)) {
...

Note that I have two alternations with 'unlikely' because using '!r'
alone will not give me a match. I guess the isomorphism is skipped for
some reason when used as an argument of unlikely. If so, is it possible
to enforce it somehow? Or would it be even better to make 'unlikely' an
isomorphism itself, so that the semantic patch doesn't need to know
anything about 'unlikely'?

Thanks,

   Wolfram

             reply	other threads:[~2013-05-20 17:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 17:34 Wolfram Sang [this message]
2013-05-20 17:47 ` [Cocci] isomorphism with unlikely Lars-Peter Clausen
2013-05-20 18:24   ` Wolfram Sang
2013-05-20 18:26     ` Lars-Peter Clausen
2013-05-20 18:51       ` Julia Lawall
2013-05-20 19:13         ` Lars-Peter Clausen
2013-05-22 17:36           ` Julia Lawall
2013-05-26 20:01           ` Julia Lawall

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=20130520173406.GB5890@katana \
    --to=wsa@the-dreams.de \
    --cc=cocci@systeme.lip6.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.