From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avo7F-0004KT-Q8 for qemu-devel@nongnu.org; Thu, 28 Apr 2016 11:44:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avo7A-0003m0-Ny for qemu-devel@nongnu.org; Thu, 28 Apr 2016 11:44:33 -0400 References: <1461801715-24307-1-git-send-email-eblake@redhat.com> <1461801715-24307-23-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <57222FDA.5080909@redhat.com> Date: Thu, 28 Apr 2016 09:44:26 -0600 MIME-Version: 1.0 In-Reply-To: <1461801715-24307-23-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RN6j1AM9Q1AgIEh2vktRSX8mbG8pL4HOo" Subject: Re: [Qemu-devel] [PATCH v15 22/23] qapi: Simplify semantics of visit_next_list() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexander Graf , David Gibson , "open list:sPAPR" , armbru@redhat.com, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --RN6j1AM9Q1AgIEh2vktRSX8mbG8pL4HOo Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/27/2016 06:01 PM, Eric Blake wrote: > The semantics of the list visit are somewhat baroque, with the > following pseudocode when FooList is used: >=20 >=20 > We can greatly simplify things by hoisting the special case > into the start() routine, and flipping the order in the loop > to visit before advance: >=20 > start(head) > for (tail =3D *head; tail; tail =3D next(tail)) { > visit(&tail->value) > } >=20 > +++ b/qapi/qapi-visit-core.c > @@ -48,15 +48,17 @@ void visit_end_struct(Visitor *v) > v->end_struct(v); > } >=20 > -void visit_start_list(Visitor *v, const char *name, Error **errp) > +void visit_start_list(Visitor *v, const char *name, GenericList **list= , > + size_t size, Error **errp) > { > - v->start_list(v, name, errp); > + assert(!list || size >=3D sizeof(GenericList)); > + v->start_list(v, name, list, size, errp); > } As mentioned in 02/23, this would be a good place to assert that: if (v->type =3D=3D VISITOR_INPUT) { assert(!(err && *list)); } of course, that means declaring a local 'err'. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --RN6j1AM9Q1AgIEh2vktRSX8mbG8pL4HOo 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/ iQEcBAEBCAAGBQJXIi/aAAoJEKeha0olJ0Nqj1sIAKVgerGJvu/7oV4qA8B8UdxB O0BlYyzhpsX8Emsl3fN622gpHdrOtci3zR8clZ/FsZFaRqbH77dogAacSJU5CUDZ jAi/GLOi5Q4WcOSSkMqNTCjaMnAwvPzy/Do2reCe4J/qHN5oORKipcBR8G599H9v qkOtt7WY6KpjWhqRp6kKXUI4nDVUBZMKn9EAp0TX+Q7IjA4c+IL3/MRosDk4r130 y8/xppNlXhIP5pBdiKDykE+uCQHx34cOoKQi/IBQL0ozIKlayAdBLO/g4/fqXJjw nNfSEM6KBg1AAeNTSeuaMfKlMV9KwmVuNZ0juI6lRCePTbEXAo97DYCVBvInYeo= =PeMY -----END PGP SIGNATURE----- --RN6j1AM9Q1AgIEh2vktRSX8mbG8pL4HOo--