From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGTSJ-0002Xp-M4 for qemu-devel@nongnu.org; Tue, 05 Jan 2016 10:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aGTSE-0001ZY-Mp for qemu-devel@nongnu.org; Tue, 05 Jan 2016 10:23:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGTSE-0001ZS-HA for qemu-devel@nongnu.org; Tue, 05 Jan 2016 10:23:22 -0500 References: <1450717720-9627-1-git-send-email-eblake@redhat.com> <1450717720-9627-13-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <568BDFE9.707@redhat.com> Date: Tue, 5 Jan 2016 08:23:21 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bOLiqpTKBvwN0cUL0SQSxq5hDeiBR79xl" Subject: Re: [Qemu-devel] [PATCH v8 12/35] qapi: Don't cast Enum* to int* List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= Cc: Michael Roth , QEMU , Markus Armbruster This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --bOLiqpTKBvwN0cUL0SQSxq5hDeiBR79xl Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/05/2016 07:06 AM, Marc-Andr=C3=A9 Lureau wrote: > Hi >=20 > On Mon, Dec 21, 2015 at 6:08 PM, Eric Blake wrote: >> C compilers are allowed to represent enums as a smaller type >> than int, if all enum values fit in the smaller type. There >> are even compiler flags that force the use of this smaller >> representation, and using them changes the ABI of a binary. >> Therefore, our generated code for visit_type_ENUM() (for all >> qapi enums) was wrong for casting Enum* to int* when calling >> visit_type_enum(). >> >> It appears that no one has been doing this for qemu, because >> if they had, we are potentially dereferencing beyond bounds >> or even risking a SIGBUS on platforms where unaligned pointer >> dereferencing is fatal. Better is to avoid the practice >> entirely, and just use the correct types. >> >> This matches the fix for alternate qapi types, done earlier in >> "qapi: Simplify visiting of alternate types". When I first wrote this commit message, commit 0426d53 wasn't yet in mainline. Maintainer can touch up the message to call out the id, if desired. >> >> Signed-off-by: Eric Blake >=20 > Reviewed-by: Marc-Andr=C3=A9 Lureau >=20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --bOLiqpTKBvwN0cUL0SQSxq5hDeiBR79xl 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/ iQEcBAEBCAAGBQJWi9/pAAoJEKeha0olJ0NqQLYH/ia7Y1f+MM9Rx6hPlnu/ieZy 7UoxekK3GRCicdfaPRxw+WDD6UgRN50XVwfoDiS2g49YaIP7J9FbwULJmc3k0asN sjMzapVoC2hBf8/QcLWjoNCHPeSvfSuioK6RN/qB9ABuVEKHBIy1qiuWn/Pia7ND w5NIQ8Dag1eWi9ytmRTe91USUsr2DC4E3y6sKHXCTrT+bhweKtAM2Ar8xMxNUd2Y SoPA4slxzic/Kv6eSH7/SzNM1n+Su0EC3/DZlzOFXEQ+EHNc3laKR+F4Vx8y3Ikh GIj4EEX+s/eT58d8WIn6Qnh/R+VCVMxwDlNi9afqXocpJFvgpOH1g0KHC7Bux1I= =WdZA -----END PGP SIGNATURE----- --bOLiqpTKBvwN0cUL0SQSxq5hDeiBR79xl--