[Cocci] Re: problems with typecasts
c-d.hailfinger.devel.2006 at gmx.net
Thu Mar 5 17:13:49 CET 2009
On 05.03.2009 16:31, Julia Lawall wrote:
> On Thu, 5 Mar 2009, Carl-Daniel Hailfinger wrote:
>> sorry for posting an immediate followup, but I had some progress on
>> removing redundancies from the semantic patch. However, it seems I
>> misread the SmPL grammar somewhere because I now get an error from spatch:
>> Fatal error: exception Failure("minus: parse error:
>> = File "writeb.cocci", line 21, column 0, charpos = 197
>> around = '|', whole content = |
> In an ( | ) the different possibilities have to be proper terms
> (statements, expressions, whatever). In your case, you have eg
> "writeb(a," which is not an anything.
That explains my earlier failed attempts as well.
> If you really want to combine them,
> you could say:
> - (T)
> (Note that there is a space before the ( in the sixth line)
Unfortunately, that semantic patch does not match any code with read
because read only takes one parameter and the pattern has a comma. If I
remove the comma from the pattern, spatch complains about invalid syntax.
> For the problem with parentheses, a possibility is to do the following,
> etc for the read case:
> - a = *(b)
> + a = readb(b)
Unfortunately, that won't work match the statement below because there
are no parentheses around b.
id2 = *(volatile uint8_t *)(bios + 0x01);
> In your standard.iso file you should have:
> @ paren @
> expression E;
> (E) => E
Yes, that's inside my standard.iso.
> This means that something with a parenthesis will match something without
> it as well. So the above will also match a = *b.
Good to know. There's probably some code where this feature will help me.
More information about the Cocci