On Thu, Dec 15, 2011 at 12:11:32PM +0100, Julia Lawall wrote: > I was hoping that you could write > > @@ struct task_struct *task; statement S1,S2; @@ > if ( > - (task)->pid == 0 > + is_idle_task(task) > || ...) S1 else S2 > > and have it do everything. Because with S1 and S2 as the then and > else branches, there is an isomorphism to flip the branches while > negating the test expression. Then the intention was that it would > push the ! in to the ==, making it a !=. Unfortunately, though this > doesn't work, because it sees the ! as part of the context and == as > part of the removed code. So it works fine if you are just doing > matching, but not transformation. > > So I think the best solution would be to stick with the separate == > and != rules.
I guess I'd hope that an isomorphism could determine the equivalence between: @@ ... @@ - variable == 0 + condition and @@ ... @@ - variable != 0 + !condition . That seems like a fairly simple equivalence (possibly by way of an isomorphism between !(variable == 0) and (variable != 0)). - Josh Triplett _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
