From patchwork Thu Sep 11 23:20:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 388438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D994614017D for ; Fri, 12 Sep 2014 09:21:56 +1000 (EST) Received: from localhost ([::1]:41629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSDgY-0000or-VG for incoming@patchwork.ozlabs.org; Thu, 11 Sep 2014 19:21:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSDfw-0008JH-VR for qemu-devel@nongnu.org; Thu, 11 Sep 2014 19:21:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSDfo-0003WF-RC for qemu-devel@nongnu.org; Thu, 11 Sep 2014 19:21:16 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:47456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSDfo-0003W2-HU for qemu-devel@nongnu.org; Thu, 11 Sep 2014 19:21:08 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 11 Sep 2014 19:21:08 -0400 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 11 Sep 2014 19:21:06 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id B01336E803F; Thu, 11 Sep 2014 19:20:53 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s8BNL5nI9044272; Thu, 11 Sep 2014 23:21:05 GMT Received: from d01av04.pok.ibm.com (localhost [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s8BNL5T0028467; Thu, 11 Sep 2014 19:21:05 -0400 Received: from localhost (morrigu.austin.ibm.com [9.41.105.45]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s8BNL5Y4028451; Thu, 11 Sep 2014 19:21:05 -0400 From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 11 Sep 2014 18:20:58 -0500 Message-Id: <1410477659-9163-3-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410477659-9163-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1410477659-9163-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14091123-5806-0000-0000-000000719A9C X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.182.137 Cc: famz@redhat.com, armbru@redhat.com, qemu-stable@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 2/3] qapi: dealloc visitor, implement visit_start_union X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If the .data field of a QAPI Union is NULL, we don't need to free any of the union fields.. Make use of the new visit_start_union interface to access this information and instruct the generated code to not visit these fields when this occurs. Cc: qemu-stable@nongnu.org Reported-by: Fam Zheng Suggested-by: Paolo Bonzini Signed-off-by: Michael Roth --- qapi/qapi-dealloc-visitor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index dc53545..eb77078 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -162,6 +162,11 @@ static void qapi_dealloc_type_enum(Visitor *v, int *obj, const char *strings[], { } +static bool qapi_dealloc_start_union(Visitor *v, bool data_present, Error **errp) +{ + return data_present; +} + Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v) { return &v->visitor; @@ -191,6 +196,7 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void) v->visitor.type_str = qapi_dealloc_type_str; v->visitor.type_number = qapi_dealloc_type_number; v->visitor.type_size = qapi_dealloc_type_size; + v->visitor.start_union = qapi_dealloc_start_union; QTAILQ_INIT(&v->stack);