From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8piN-0008D8-R2 for qemu-devel@nongnu.org; Fri, 03 Jun 2016 10:04:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8piJ-0006r7-KT for qemu-devel@nongnu.org; Fri, 03 Jun 2016 10:04:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53959) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8piJ-0006r2-Eu for qemu-devel@nongnu.org; Fri, 03 Jun 2016 10:04:39 -0400 From: Markus Armbruster References: <1463632874-28559-1-git-send-email-eblake@redhat.com> <1463632874-28559-14-git-send-email-eblake@redhat.com> <8737oviu3s.fsf@dusky.pond.sub.org> Date: Fri, 03 Jun 2016 16:04:36 +0200 In-Reply-To: <8737oviu3s.fsf@dusky.pond.sub.org> (Markus Armbruster's message of "Thu, 02 Jun 2016 15:43:51 +0200") Message-ID: <87eg8ev05n.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 13/28] qapi: Add new clone visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Michael Roth Markus Armbruster writes: > Eric Blake writes: [...] >> diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c >> index 279ea8e..c5bdca2 100644 >> --- a/qapi/qapi-visit-core.c >> +++ b/qapi/qapi-visit-core.c [...] >> @@ -44,10 +44,10 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, >> >> if (obj) { >> assert(size); >> - assert(v->type != VISITOR_OUTPUT || *obj); >> + assert(!(v->type & VISITOR_OUTPUT) || *obj); >> } > > For real walks (obj != NULL): > > * Input visitors write *obj, and don't care for the old value. > > * Output visitors read *obj, and a struct can't be null. > > * The dealloc visitor reads *obj, but null is fine (partially > constructed object). > > * The clone visitor reads like an output visitor (except at the root) > and writes like an input visitor. > > Before the patch, we assert "if output visitor, then *obj isn't null". > > After the patch, we do the same for the clone visitor. Correct, except > at the root. There, @obj points to qapi_clone()'s @dst, which is > uninitialized. I'm afraid this assertion fails if @dst happens to be > null. I can observe this failure in make check when I compile with optimization. [...]