From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLzmF-0008GH-KE for qemu-devel@nongnu.org; Wed, 20 Jan 2016 15:54:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLzmE-0002UB-8t for qemu-devel@nongnu.org; Wed, 20 Jan 2016 15:54:51 -0500 References: <1453219845-30939-1-git-send-email-eblake@redhat.com> <1453219845-30939-16-git-send-email-eblake@redhat.com> <874me8m6h0.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <569FF411.3080005@redhat.com> Date: Wed, 20 Jan 2016 13:54:41 -0700 MIME-Version: 1.0 In-Reply-To: <874me8m6h0.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="urrESOLFPAh83f41uPDHmiACbECo1Udka" Subject: Re: [Qemu-devel] [PATCH v9 15/37] qom: Swap 'name' next to visitor in ObjectPropertyAccessor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , Eduardo Habkost , "open list:nvme" , "Michael S. Tsirkin" , John Snow , Jason Wang , qemu-devel@nongnu.org, Alexander Graf , Keith Busch , marcandre.lureau@redhat.com, Gonglei , "open list:sPAPR" , Gerd Hoffmann , Igor Mammedov , Paolo Bonzini , Richard Henderson , Jiri Slaby , =?UTF-8?Q?Andreas_F=c3=a4rber?= , David Gibson This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --urrESOLFPAh83f41uPDHmiACbECo1Udka Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/20/2016 11:49 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Similar to the previous patch, it's nice to have all functions >> in the tree that involve a visitor and a name for conversion to >> or from QAPI to consistently stick the 'name' parameter next >> to the Visitor parameter. >> >> Done by manually changing include/qom/object.h and qom/object.c, >> then running this Coccinelle script and touching up the fallout >> (Coccinelle insisted on adding some trailing whitespace). >> >> @ rule1 @ >> identifier fn; >> type Object, Visitor, Error; >> identifier obj, v, opaque, name, errp; >> @@ >> void fn >> - (Object *obj, Visitor *v, void *opaque, const char *name, >> + (Object *obj, Visitor *v, const char *name, void *opaque, >> Error **errp) { ... } >=20 > I think we want to match void functions with exactly these parameter > types. The parameter names don't matter. The parameter names shouldn't matter; the 'identifier obj' should have been enough to make 'obj' a metavariable matching any actual parameter na= me. >=20 > However, the actual match is looser! For instance, it also matches >=20 > void foo(int *pi, unsigned *pu, void *vp, const char *cp, double **= dpp) > { > } Uggh. My intent was to match exactly 'Object *' and 'Visitor *' as the first two types, where 'int *' and 'unsigned *' are NOT matches. But I don't know Coccinelle well enough to make that blatantly obvious (is my declaration of 'type Object' not correct?). >=20 > This could mess up unrelated function. I could double-check it doesn't= , > but I'd rather have a narrower match instead. Can't give one offhand, > though. Ideas? Is 'typedef' better than 'type' for constraining the type of the first two arguments? Or does Coccinelle do literal matches on anything you don't pre-declare, as in: @ rule1 @ identifier fn; identifier obj, v, opaque, name, errp; @@ void fn - (Object *obj, Visitor *v, void *opaque, const char *name, + (Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { ... } Fortunately, a manual inspection of the results (which I had to do anyways due to spacing issues) didn't spot any incorrect swaps. At this point, I don't know that re-writing Coccinelle will be worth the hassle (nothing else needs to be rewritten). >=20 >> >> @@ >> identifier rule1.fn; >> expression obj, v, opaque, name, errp; >> @@ >> fn(obj, v, >> - opaque, name, >> + name, opaque, >> errp) >=20 > The rule1.fn restricts the match to functions changed by the previous > rule. Good. >=20 >> >> Signed-off-by: Eric Blake >> Reviewed-by: Marc-Andr=C3=A9 Lureau >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --urrESOLFPAh83f41uPDHmiACbECo1Udka Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWn/QRAAoJEKeha0olJ0NqLWIH/iYVdO6TUn984Pbc+Z08X32m SlaAAYwOMxON9tgdwSghvTPuf7cO3/ulBlf4TFg80RHkPvfaMGv8+Gset+VXCjS1 QyrOIdz0UeElEDS+Q8nke/zktm2FV2/BMRAzHP2S664DTCU5QB90JvqFYkvH8oAg +lB2Ft/dRUD4mBxKvxcujJ7zKGLAWKTxkVmZ3FfhpOD+VF6siKpMrd2J8F72dV27 O8uL7O9gS3Pn6e99Mspy4c6+rfJLf4gHFHl6UjQk2VWCuouHWCkznT5XTex0ujYq MJWpjRi3uW+o6wcqMvTAwA0OsQfifG/RwXPGX0pYfiU1puyp9kWTkeyRf28iKdI= =FejR -----END PGP SIGNATURE----- --urrESOLFPAh83f41uPDHmiACbECo1Udka--