All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Patching nested if's?
@ 2015-03-31 12:56 François Armand
  2015-03-31 13:15 ` SF Markus Elfring
  2015-03-31 13:47 ` Julia Lawall
  0 siblings, 2 replies; 8+ messages in thread
From: François Armand @ 2015-03-31 12:56 UTC (permalink / raw)
  To: cocci

Hi,

I'd like to patch the third if of a code block that looks like:

if (MY_SUCCESS != ret) {
      if (MY_EPERM != ret &&  MY_ENOENT != ret) {
          if (t < MAXR) {
              foo();
              goto retry;
          } else {
              bar();
          }
      }
}

I'd like to get:


if (MY_SUCCESS != ret) {
      if (MY_EPERM != ret &&  MY_ENOENT != ret) {
          if (myfunc() == 0) {
              goto retry;
          } else {
              bar();
          }
      }
}

I've been able so far to replace the if (t <MAXR) but this
also replaces lines with it (expresion < constant) elsewhere.
Which is why I'd like to constrain the pacth to this 3 nested
ifs pattern.

Removing calls to foo() is easy, since I want to remove them all.

I came up with the following invalid attempt
@@
expression t;
constant M;
@@
 if (...)
    if (...)
    {
       if (
-       t < M
+          myfunc()
          )
          {
      ...
      } else {
      ...
      }
    }
  }

Thanks for any hint.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20150331/092cd2c1/attachment.html>

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

end of thread, other threads:[~2015-03-31 16:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-31 12:56 [Cocci] Patching nested if's? François Armand
2015-03-31 13:15 ` SF Markus Elfring
2015-03-31 13:47 ` Julia Lawall
2015-03-31 15:18   ` François Armand
2015-03-31 15:49     ` Julia Lawall
2015-03-31 16:06       ` François Armand
2015-03-31 16:11         ` Julia Lawall
2015-03-31 16:12           ` François Armand

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.