From patchwork Fri May 16 15:30:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 349649 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 47649140090 for ; Sat, 17 May 2014 01:34:23 +1000 (EST) Received: from localhost ([::1]:36356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlK9M-0001CQ-Tt for incoming@patchwork.ozlabs.org; Fri, 16 May 2014 11:34:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlK6F-0003Zr-Ir for qemu-devel@nongnu.org; Fri, 16 May 2014 11:31:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlK69-0006GP-72 for qemu-devel@nongnu.org; Fri, 16 May 2014 11:31:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlK68-0006GD-Uf for qemu-devel@nongnu.org; Fri, 16 May 2014 11:31:01 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFUicm011410 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 May 2014 11:30:56 -0400 Received: from localhost (ovpn-113-132.phx2.redhat.com [10.3.113.132]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFUhE3019530; Fri, 16 May 2014 11:30:44 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Fri, 16 May 2014 11:30:21 -0400 Message-Id: <1400254235-9435-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1400254235-9435-1-git-send-email-lcapitulino@redhat.com> References: <1400254235-9435-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 06/20] qapi: Clean up shadowing of parameters and locals in inner scopes 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 From: Markus Armbruster By un-inlining the visit of nested complex types. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- scripts/qapi-visit.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 28176ba..57be9bf 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -35,6 +35,19 @@ def generate_visit_struct_fields(name, field_prefix, fn_prefix, members, base = nested_field_prefix = "%s%s." % (field_prefix, argname) ret += generate_visit_struct_fields(name, nested_field_prefix, nested_fn_prefix, argentry) + ret += mcgen(''' + +static void visit_type_%(full_name)s_field_%(c_name)s(Visitor *m, %(name)s **obj, Error **errp) +{ + Error *err = NULL; +''', + name=name, full_name=full_name, c_name=c_var(argname)) + push_indent() + ret += generate_visit_struct_body(full_name, argname, argentry) + pop_indent() + ret += mcgen(''' +} +''') ret += mcgen(''' @@ -69,7 +82,10 @@ if ((*obj)->%(prefix)shas_%(c_name)s) { push_indent() if structured: - ret += generate_visit_struct_body(full_name, argname, argentry) + ret += mcgen(''' +visit_type_%(full_name)s_field_%(c_name)s(m, obj, &err); +''', + full_name=full_name, c_name=c_var(argname)) else: ret += mcgen(''' visit_type_%(type)s(m, &(*obj)->%(c_prefix)s%(c_name)s, "%(name)s", &err); @@ -106,8 +122,6 @@ if (!error_is_set(errp)) { if len(field_prefix): ret += mcgen(''' -Error **errp = &err; /* from outer scope */ -Error *err = NULL; visit_start_struct(m, NULL, "", "%(name)s", 0, &err); ''', name=name)