On Mon, 31 Oct 2011, Russell King wrote:

> Is there a neater way to write this:
> 
> @ rule1 @
> identifier fn;
> @@
> arch_reset = fn;
> @@
> identifier rule1.fn, mode, cmd;
> @@
> void fn(char mode, const char *cmd)
> {
> ...
> - local_irq_disable();
> ...
> }
> @@
> identifier mode, cmd;
> @@
> arch_reset(char mode, const char *cmd)
> {
> ...
> - local_irq_disable();
> ...
> }
> 
> The idea is to remove calls to local_irq_disable() inside any function
> to do with the arch_reset().  Some ARM platforms define this as an inline
> function, others define arch_reset() as a pointer, and assign some other
> function to that pointer.
> 
> I'm wondering whether there's a way to express both conditions with
> the 'fn' identifier above.

No, I don't think so.  For your

  ...
- local_irq_disable();
  ...

put instead:

  <...
- local_irq_disable();
  ...>

Then you will remove all of the calls.  In your version, it would actually 
remove a call in the case where there is exactly one, because ... takes 
the shortest path between something that matches what is before and what 
is after.

You don't want to do anything with local_irq_enable?

julia

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

Reply via email to