From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzPst-0006Nm-7W for qemu-devel@nongnu.org; Thu, 19 Nov 2015 09:08:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzPsp-0005K7-1d for qemu-devel@nongnu.org; Thu, 19 Nov 2015 09:08:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzPso-0005Jr-SG for qemu-devel@nongnu.org; Thu, 19 Nov 2015 09:08:18 -0500 References: <1447836791-369-1-git-send-email-eblake@redhat.com> <1447836791-369-32-git-send-email-eblake@redhat.com> <874mgjjgbw.fsf@blackfin.pond.sub.org> <564CDAAC.3030200@redhat.com> <87wptee7ud.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <564DD7CC.9050705@redhat.com> Date: Thu, 19 Nov 2015 07:08:12 -0700 MIME-Version: 1.0 In-Reply-To: <87wptee7ud.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6qCB36FRfGk2lKnlSCBpVWHutiXfOfOTI" Subject: Re: [Qemu-devel] [PATCH v12 31/36] qapi: Simplify visiting of alternate types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6qCB36FRfGk2lKnlSCBpVWHutiXfOfOTI Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/19/2015 01:01 AM, Markus Armbruster wrote: >>>> This has a couple of subtle bugs. First, the generator was >>>> creating a call with a parameter '(int *) &(*obj)->type' where >>>> type is an enum type; this is unsafe if the compiler chooses >>>> to store the enum type in a different size than int, where >>>> assigning through the wrong size pointer can corrupt data or >>>> cause a SIGBUS. [We still have the casting bug for our enum >>>> visitors, but that's a topic for a different patch.] >>> >>> I'm not sure I get the last sentence. >> >> I was referring to our casts of enum types to int* inside visit_type_E= num(): >> https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg03408.html >> >> If you have a better wording for it, or want to drop the parenthetical= >> altogether, I'm fine. >=20 > What about this: replace the parenthetical with >=20 > Related bug, not fixed in this patch: qapi-visit.py's > gen_visit_enum() generates a cast of its enum * argument to int *. > Marked FIXME. >=20 > and squash in >=20 > diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py > index e8b53b3..4797d6e 100644 > --- a/scripts/qapi-visit.py > +++ b/scripts/qapi-visit.py > @@ -172,6 +172,7 @@ out: > =20 > =20 > def gen_visit_enum(name): > + # FIXME cast from enum *obj to int * invalidly assumes enum is int= > return mcgen(''' That works for me. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --6qCB36FRfGk2lKnlSCBpVWHutiXfOfOTI 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/ iQEcBAEBCAAGBQJWTdfMAAoJEKeha0olJ0NqxG0H/RWx4lywJe6UHHOmPU2T0aer sM/d0sIrO0lqF/pfCuM3aKP9m4as4/N0/m/eM+uC6NCZ7J/UayPMbyUvrP11lWtO OdFgPM/6fgrCxLXHacrGScV7KqHWr6pCMvNn6fnrYeN23uL/0vBoxYMbgqF3H2/E f/KJqjcYMCzVDYKUVBesrBQ5ukRC394kF4vnp4Q7/xXTW5NLhivJ2elXM5Eog1ra eLop/0Nu9fbH1Ydo7A/+TsNRBU0efBxGGRWGYjHhiWqgou76RfLpmUOep7EBniYe kccPE7wbbe5MsDVTmmN2EK1mN/i9X7Dj935Xd7ktMBNxZeJrjY5TA6fRnYxADfU= =Rmh+ -----END PGP SIGNATURE----- --6qCB36FRfGk2lKnlSCBpVWHutiXfOfOTI--