[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] add macro file for coccinelle

From: John Snow
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] add macro file for coccinelle
Date: Thu, 10 Sep 2015 17:23:53 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 09/09/2015 05:51 AM, Paolo Bonzini wrote:
> On 08/09/2015 20:35, Markus Armbruster wrote:
>>>> Having not used Coccinelle yet, what happens if any of these functions
>>>> become desynchronized ?
>> Coccinelle transforms C to C.  Problem: if you parse C the normal way
>> (first run preprocessor, then the parser proper), you have to unparse
>> and unpreprocess at the end to get a useful result.  Unparsing is easy,
>> but unpreprocessing is hard.
>> Instead, Coccinelle tries to parse *unpreprocessed* C.  Works most of
>> the time, because most uses of function-like macros can be treated as if
>> they were function calls, and most uses of object-like macros can be
>> treated as if they were values.
>> When it doesn't work, Coccinelle needs to resort to magic and / or skip
>> over some code it can't decipher.  The latter is undesirable, because if
>> the skipped code contains something we'd like to transform, we won't.
>> Part of the magic is treating "bad" macros specially.  --macro-file
>> helps with that part: macros defined there are "bad".  Sorry, I can't
>> really explain it, -EMAGIC.  /usr/share/coccinelle/standard.h is used by
>> default.
>> So what happens when the this file gets out of sync?  Worst case is
>> Coccinelle misses a pattern it could find if it was in sync.
>> Provided the macro file makes sense initially, a moderately bit-rotten
>> version is still almost certainly better than nothing.
> Great answer.  I'll only add that exactly the same issue happens with
> the Coverity model.
> Paolo

Great, thanks for the info :)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]