Received: from eggs.gnu.org ([2001:4830:134:3::10]:54249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeliX-0001cA-Mp for qemu-devel@nongnu.org; Wed, 23 Sep 2015 11:12:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeliT-0002pa-Fo for qemu-devel@nongnu.org; Wed, 23 Sep 2015 11:12:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeliT-0002pU-B9 for qemu-devel@nongnu.org; Wed, 23 Sep 2015 11:12:17 -0400 From: Markus Armbruster References: <1442872682-6523-1-git-send-email-eblake@redhat.com> <1442872682-6523-4-git-send-email-eblake@redhat.com> <87h9mmfpf7.fsf@blackfin.pond.sub.org> <5601955B.4050109@redhat.com> <87a8sda2t8.fsf@blackfin.pond.sub.org> <56029F04.3040407@redhat.com> <87r3lp5j4f.fsf@blackfin.pond.sub.org> <5602B4EE.8010903@redhat.com> Date: Wed, 23 Sep 2015 17:12:13 +0200 In-Reply-To: <5602B4EE.8010903@redhat.com> (Eric Blake's message of "Wed, 23 Sep 2015 08:19:26 -0600") Message-ID: <87y4fxxj8y.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v5 03/46] qapi: Test for C member name collisions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, marcandre.lureau@redhat.com, Michael Roth , ehabkost@redhat.com, DirtY.iCE.hu@gmail.com Eric Blake writes: > On 09/23/2015 08:02 AM, Markus Armbruster wrote: > >>> However, I'm not sure it would always help. The conversion of >>> netdev_add to full qapi relies on being able to access the variant >>> through a named struct (such as NetdevTapOptions); unboxing the variant >>> would get rid of the convenient access to these named sub-structs. >> >> struct Union { >> EnumType type; >> /* union tag is @type */ >> union { >> One one; >> Two two; >> }; >> }; >> >> For base, we go one step further and peel off the struct, to save some >> notational overhead. Pointless for unions. > > Ah, I see. Instead of malloc'ing a sub-struct and calling (roughly) > > ptr = visit_start_struct(Union) // mallocs > subptr = visit_start_implicit_struct(One) // also mallocs > visit_type_fields(subptr) > visit_end_implicit_struct() > > we would instead use inline allocation, with: > > ptr = visit_start_struct(Union) // mallocs > visit_type_fields(&ptr->one) > > seems straightforward enough; I'll play with the idea on top of my series. I should be careful what I wish for lest the series grows faster than I can review it!