From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZc2L-00008p-33 for qemu-devel@nongnu.org; Wed, 09 Sep 2015 05:51:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZc2H-0002NC-Sh for qemu-devel@nongnu.org; Wed, 09 Sep 2015 05:51:29 -0400 References: <1441621264-23812-1-git-send-email-pbonzini@redhat.com> <55EF1B31.6070504@redhat.com> <87r3m8g3na.fsf@blackfin.pond.sub.org> From: Paolo Bonzini Message-ID: <55F00119.4000305@redhat.com> Date: Wed, 9 Sep 2015 11:51:21 +0200 MIME-Version: 1.0 In-Reply-To: <87r3m8g3na.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] add macro file for coccinelle List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , John Snow Cc: qemu-trivial@nongnu.org, peter.maydell@linaro.org, qemu-devel@nongnu.org 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