From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b88Bu-0000nn-DV for qemu-devel@nongnu.org; Wed, 01 Jun 2016 11:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b88Bt-0002Lv-Ex for qemu-devel@nongnu.org; Wed, 01 Jun 2016 11:36:18 -0400 From: Markus Armbruster References: <1463632874-28559-1-git-send-email-eblake@redhat.com> <1463632874-28559-5-git-send-email-eblake@redhat.com> Date: Wed, 01 Jun 2016 17:36:07 +0200 In-Reply-To: <1463632874-28559-5-git-send-email-eblake@redhat.com> (Eric Blake's message of "Wed, 18 May 2016 22:40:50 -0600") Message-ID: <87y46oq5ug.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 04/28] qapi: Add parameter to visit_end_* List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Kevin Wolf , "open list:Block layer core" , "Michael S. Tsirkin" , Michael Roth , Alexander Graf , "open list:sPAPR" , Max Reitz , Andreas =?utf-8?Q?F=C3=A4rber?= , David Gibson Eric Blake writes: > Rather than making the dealloc visitor track of stack of pointers > remembered during visit_start_* in order to free them during > visit_end_*, it's a lot easier to just make all callers pass the > same pointer to visit_end_*. The generated code has access to the > same pointer, while all other users are doing virtual walks and > can pass NULL. The dealloc visitor is then greatly simplified. > > All three visit_end_*() functions intentionally take a void**, > even though the visit_start_*() functions differ between void**, > GenericList**, and GenericAlternate**. This is done for several > reasons: when doing a virtual walk, passing NULL doesn't care > what the type is, but when doing a generated walk, we already > have to cast the caller's specific FOO* to call visit_start, > while using void** lets us use visit_end without a cast. Also, > an upcoming patch will add a clone visitor that wants to use > the same implementation for all three visit_end callbacks, > which is made easier if all three share the same signature. > > Signed-off-by: Eric Blake [...] > diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c > index aea90a1..84f32fc 100644 > --- a/qapi/qmp-input-visitor.c > +++ b/qapi/qmp-input-visitor.c > @@ -145,7 +145,7 @@ static void qmp_input_check_struct(Visitor *v, Error **errp) > } > } > > -static void qmp_input_pop(Visitor *v) > +static void qmp_input_pop(Visitor *v, void **obj) > { > QmpInputVisitor *qiv = to_qiv(v); > StackObject *tos = &qiv->stack[qiv->nb_stack - 1]; You could assert @obj matches tos->obj. Same for the other visitors that still need a stack. Adding a stack to the ones that don't just for the assertion seems excessive, though. [...]