Received: from eggs.gnu.org ([2001:4830:134:3::10]:44811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLX70-00021c-W9 for qemu-devel@nongnu.org; Wed, 11 Feb 2015 08:13:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLX70-000178-7X for qemu-devel@nongnu.org; Wed, 11 Feb 2015 08:13:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLX6z-000174-VB for qemu-devel@nongnu.org; Wed, 11 Feb 2015 08:13:50 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1BDDnl1024337 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 11 Feb 2015 08:13:49 -0500 Date: Wed, 11 Feb 2015 11:13:46 -0200 From: Eduardo Habkost Message-ID: <20150211131346.GT30651@thinpad.lan.raisama.net> References: <1423586055-4932-1-git-send-email-armbru@redhat.com> <1423586055-4932-2-git-send-email-armbru@redhat.com> <54DA358B.9060509@redhat.com> <20150210220434.GB31950@thinpad.lan.raisama.net> <54DB2C44.1080904@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54DB2C44.1080904@redhat.com> Subject: [Qemu-devel] Coccinelle semantic patches (was Re: [PATCH 1/9] error: New convenience function error_report_err()) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel , Markus Armbruster On Wed, Feb 11, 2015 at 11:17:40AM +0100, Paolo Bonzini wrote: > > > On 10/02/2015 23:04, Eduardo Habkost wrote: > > $ spatch --sp-file /tmp/error_report.spatch $(git grep -l error_report) > /tmp/error_report.patch > > Does it work without specifying any include path? I didn't even know it had include path options. I don't know what it would use it for (I guess there are some use cases where parsing the include files would be useful, but I am not aware of them). > > I tried this a while ago: > > @@ > identifier s, fld; > @@ > struct s { > ... > - QEMUTimer *fld; > + QEMUTimer fld; > ... > } > @@ > expression E; > identifier fld; > @@ > - E->fld = timer_new_ms( > + timer_init_ms(&E->fld, > ... > ); > > > (The patch is incomplete, but shows the problem). "spatch --sp-file > timer.cocci hw/arm/pxa2xx.c" misses the first replacement for struct > PXA2xxRTCState, but "spatch --sp-file timer.cocci hmp.c" does it right > in struct MigrationStatus. That's because your rule doesn't match the PXA2xxRTCState declaration, that is written as "typedef struct { ... } PXA2xxRTCState", and hence doesn't match the "struct s { ... }" pattern. I don't know how to write a rule that matches both (the "\( a \| b \)" format seems to work only inside statement lists). As a good plier-wielding ogre, I would give up and simply write two rules: @@ identifier fld; @@ struct { ... - QEMUTimer *fld; + QEMUTimer fld; ... } @@ identifier s, fld; @@ struct s { ... - QEMUTimer *fld; + QEMUTimer fld; ... } @@ expression E; identifier fld; @@ - E->fld = timer_new_ms( + timer_init_ms(&E->fld, ... ); -- Eduardo