On Thu, 29 Dec 2011, Artem Bityutskiy wrote:

On Thu, 2011-12-29 at 14:32 +0100, Lars-Peter Clausen wrote:
It does not match because there is no mtd_read(&retlen) on all possible paths.
In your case there are two paths in the switch statement.
If you'd want it to match anyway you can use a subexpression. e.g.
'<+...mtd_read(&retlen)...+>'. But this has the downside that retlen might be
used uninitialized at a later point.

Thanks. I've used the "?" thingy instead, which I understand as "this
line is optional".  But I do not understand what "<+..." means.
I guess I need to read more docs, any suggestion?

Although when I first read this page:
http://www.emn.fr/z-info/coccinelle/docs/main_grammar004.html

which says "? represents at most one match of the given pattern", I
did not really understand what "?" means. Why not to phrase it in a
more human-friendly way like "? represents an optional match" :-) ?
Or I misunderstand something?

<... P ...> is a sequence with zero or more matches of P
It is sort of like the opposite of when. When forbids all occurrences, <... ...> allows all occurrences.

<+... P ...+> is a sequence with at least one match of P

?P is at most one match of P.

I can expand the description of ? to use the word optional.

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

Reply via email to