From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3RnA-0002rO-Lk for qemu-devel@nongnu.org; Tue, 23 Dec 2014 10:54:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y3Rn4-0003UP-Iv for qemu-devel@nongnu.org; Tue, 23 Dec 2014 10:54:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3Rn4-0003TQ-Av for qemu-devel@nongnu.org; Tue, 23 Dec 2014 10:54:30 -0500 Message-ID: <54999031.8060302@redhat.com> Date: Tue, 23 Dec 2014 08:54:25 -0700 From: Eric Blake MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kampdHfKAB2OgwAqi4hO9947OI9e8er0t" Subject: Re: [Qemu-devel] QAPI and empty structs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , QEMU Developers Cc: Markus Armbruster , Luiz Capitulino This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --kampdHfKAB2OgwAqi4hO9947OI9e8er0t Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/23/2014 08:50 AM, Peter Maydell wrote: > In qapi-schema.json we have a couple of entries that define > empty structures, like this: >=20 > { 'type': 'ChardevDummy', 'data': { } } >=20 > In the generated qapi-types.h these are turned into empty C structs: >=20 > Although you could argue that we don't care about differences > in C and C++ semantics, having a zero-sized struct floating > around seems a bit risky to me, since for instance a naive > attempt to g_malloc() space for it will return NULL. Oh, good point. >=20 > How should we handle these? Should the qapi-types generator > stick a dummy field in so they aren't zero sized? Sounds like the best plan to me. > Are they > actually an error in the schema? (what's the point of them?) No, they are valid - it is how you express a union between a branch that needs no additional members compared to any other branch. > Do we claim that actually all our code correctly handles > zero sized structs and just suppress the clang warning? I'd be fine with adding a dummy member. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --kampdHfKAB2OgwAqi4hO9947OI9e8er0t Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJUmZAyAAoJEKeha0olJ0Nq1bwH/1BdyL3I6sU1JC0XdeegsOXH qr3Gnmm+NfxEcTnQXKAbo+ZeO0kOIMd9wXQIaqAC8zMVTm2cZOJbui3vOvQDhBvE cMLYi6r3NtF67LofC0bwZXFXOyVI6Ewr+tpjRtII0leEpz83eS1yLfweqTDCZ2HR ePajNmzIqPfvaLJhXzJZysV66dLjkRtEnivfp8SiftNoKrRC0E0ca+hc6/s89ttu u6F15xZoAMR0Jhma3YVzhWkhSt46KAurlZ4xej0EvwYNMZpCZ5jLo74YB/p4zSar nadJnNMtSeQ3jFjqvNslZp8HxDScJy9h6kUlJ4ofzrTPv+PH+niaqlFuZ/3Xwxs= =YWEA -----END PGP SIGNATURE----- --kampdHfKAB2OgwAqi4hO9947OI9e8er0t--