On 12/16/2011 01:17 AM, Josh Triplett wrote:
> On Thu, Dec 15, 2011 at 11:56:32PM +0100, Julia Lawall wrote:
>> On Thu, 15 Dec 2011, Josh Triplett wrote:
>>> On Thu, Dec 15, 2011 at 12:11:32PM +0100, Julia Lawall wrote:
>>>> 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)).
>>
>> It's quite a nice idea, but currently the isomorphisms only affect
>> the matching part of the code.
>
> So why does it sometimes partially work? In particular, writing the
> patch with ==0 worked for both negative cases and the simpler positive
> case, and writing it with !=0 worked for all cases but produced double
> negatives in the negative cases.
The isomorphism applies to the SmPL code. If you do a spatch
-parse_cocci on your cocci file you'll see how isomorphism transforms
your SmPL code.
The trick I normally use is to add cleanup rules at the end; sometimes
that's easier than coming up with the perfect rule that does everything.
In your case you could add a rule at the end to remove the generated
double negation.
bye
michael
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)