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.
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to