All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] add macro file for coccinelle
Date: Thu, 10 Sep 2015 17:23:53 -0400	[thread overview]
Message-ID: <55F1F4E9.7040205@redhat.com> (raw)
In-Reply-To: <55F00119.4000305@redhat.com>



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 :)

--js


WARNING: multiple messages have this Message-ID (diff)
From: John Snow <jsnow@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] add macro file for coccinelle
Date: Thu, 10 Sep 2015 17:23:53 -0400	[thread overview]
Message-ID: <55F1F4E9.7040205@redhat.com> (raw)
In-Reply-To: <55F00119.4000305@redhat.com>



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 :)

--js

  reply	other threads:[~2015-09-10 21:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07 10:21 [Qemu-trivial] [PATCH v2] add macro file for coccinelle Paolo Bonzini
2015-09-07 10:21 ` [Qemu-devel] " Paolo Bonzini
2015-09-08 11:10 ` [Qemu-trivial] " Markus Armbruster
2015-09-08 11:10   ` Markus Armbruster
2015-09-08 12:44   ` [Qemu-trivial] " Paolo Bonzini
2015-09-08 12:44     ` Paolo Bonzini
2015-09-08 13:08     ` [Qemu-trivial] " Markus Armbruster
2015-09-08 13:08       ` Markus Armbruster
2015-09-08 13:31   ` [Qemu-trivial] " Marcel Apfelbaum
2015-09-08 13:31     ` [Qemu-devel] [Qemu-trivial] " Marcel Apfelbaum
2015-09-08 17:30 ` [Qemu-trivial] [Qemu-devel] " John Snow
2015-09-08 17:30   ` John Snow
2015-09-08 18:35   ` [Qemu-trivial] " Markus Armbruster
2015-09-08 18:35     ` Markus Armbruster
2015-09-09  9:51     ` [Qemu-trivial] " Paolo Bonzini
2015-09-09  9:51       ` Paolo Bonzini
2015-09-10 21:23       ` John Snow [this message]
2015-09-10 21:23         ` John Snow
2015-09-15 17:55 ` [Qemu-trivial] " Michael Tokarev
2015-09-15 17:55   ` [Qemu-devel] " Michael Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55F1F4E9.7040205@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.