On Thu, 12 Jan 2012, Robert Gomulka wrote:

Hi all,
I've tried to write rather simple patch for misplaced semicolon. Code
sample is as follows:
if (condition);
... // the rest of the code

The only solution I've come up with is:
@@
expression E;
@@

- if (E);
+ BUG(E);

Whereas I'd rather prefer something like that:
@@
expression E;
@@

if (E)
- ;

Only that it doesn't work.

The patch below
- if (E);
+ if (E)
doesn't work either.

Is there a way to write correct patch for that (removing the
semicolon)? I've tried to look for solution in web, but without
success.

It should work to say:

@@
expression E;
statement S;
@@

if (E)
- ;
  S

You may though first want to check that the if and the ; are on the same line. Sometimes people put an if like this with a semicolon alone and nicely indented on the next line, which looks intentional. You can use position variables, eg p[0].line (in python) to find out the line number. Note that line is a string rather than an integer.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to