From patchwork Fri Feb 19 12:18:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8360321 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 571219F372 for ; Fri, 19 Feb 2016 12:18:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF44B203EC for ; Fri, 19 Feb 2016 12:18:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1272F20429 for ; Fri, 19 Feb 2016 12:18:30 +0000 (UTC) Received: from localhost ([::1]:51496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWk0z-0002iq-Cv for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Feb 2016 07:18:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWk0j-0002f8-IC for qemu-devel@nongnu.org; Fri, 19 Feb 2016 07:18:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWk0i-0007bl-GN for qemu-devel@nongnu.org; Fri, 19 Feb 2016 07:18:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWk0i-0007b4-BA for qemu-devel@nongnu.org; Fri, 19 Feb 2016 07:18:12 -0500 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 (Postfix) with ESMTPS id 1350319D251 for ; Fri, 19 Feb 2016 12:18:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1JCIAlE014875 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 19 Feb 2016 07:18:11 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6FF91300384D; Fri, 19 Feb 2016 13:18:07 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 19 Feb 2016 13:18:03 +0100 Message-Id: <1455884286-26272-13-git-send-email-armbru@redhat.com> In-Reply-To: <1455884286-26272-1-git-send-email-armbru@redhat.com> References: <1455884286-26272-1-git-send-email-armbru@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 Subject: [Qemu-devel] [PULL 12/15] qapi-visit: Use common idiom in gen_visit_fields_decl() 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Blake We have several instances of methods that do an early exit if output is not needed, then log that output is being generated, and finally produce the output; see qapi-types.py:gen_object() and qapi-visit.py:gen_visit_implicit_struct(). The odd man out was gen_visit_fields_decl(); rearrange it to be more like the others. No semantic change or difference to generated code. Signed-off-by: Eric Blake Message-Id: <1455778109-6278-12-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster --- scripts/qapi-visit.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index dfeef71..d7d7ed5 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -35,15 +35,14 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error ** def gen_visit_fields_decl(typ): - ret = '' - if typ.name not in struct_fields_seen: - ret += mcgen(''' + if typ.name in struct_fields_seen: + return '' + struct_fields_seen.add(typ.name) + return mcgen(''' static void visit_type_%(c_type)s_fields(Visitor *v, %(c_type)s *obj, Error **errp); ''', - c_type=typ.c_name()) - struct_fields_seen.add(typ.name) - return ret + c_type=typ.c_name()) def gen_visit_implicit_struct(typ):