From patchwork Thu Feb 25 23:38:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8427731 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 39734C0553 for ; Thu, 25 Feb 2016 23:44:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A022C20394 for ; Thu, 25 Feb 2016 23:44:49 +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 9A6BD20266 for ; Thu, 25 Feb 2016 23:44:48 +0000 (UTC) Received: from localhost ([::1]:46472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5aR-00058R-Bb for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Feb 2016 18:44:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5V8-00037U-Rg for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZ5V3-0005Ti-Fe for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5V3-0005Tc-AU for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:13 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E8095139833; Thu, 25 Feb 2016 23:39:12 +0000 (UTC) Received: from red.redhat.com (ovpn-113-105.phx2.redhat.com [10.3.113.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1PNd2Nn002433; Thu, 25 Feb 2016 18:39:12 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 25 Feb 2016 16:38:44 -0700 Message-Id: <1456443528-13901-16-git-send-email-eblake@redhat.com> In-Reply-To: <1456443528-13901-1-git-send-email-eblake@redhat.com> References: <1456443528-13901-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 25 Feb 2016 23:39:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, Michael Roth Subject: [Qemu-devel] [PATCH v2 15/19] qapi-visit: Move error check into gen_visit_members_call() 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=-1.9 required=5.0 tests=BAYES_00, 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 When first introduced, neither branch of gen_visit_members_call() would output a goto. But now that the implicit struct visit always ends with a goto, we should do the same for regular struct visits, so that callers don't have to worry about whether they are creating two identical goto's in a row. Generated code gets slightly larger; if desired, we could patch qapi.py:gen_visit_members() to have a mode where it skips the final goto and leave it up to the callers when to use that mode, but that adds more maintenance burden when the compiler should be smart enough to not bloat the .o file just because the .c file got larger. Signed-off-by: Eric Blake --- v2: rebase onto s/fields/members/ change --- scripts/qapi-visit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index e281d21..a17ecc1 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -48,6 +48,7 @@ def gen_visit_members_call(typ, direct_name, implicit_name=None): visit_type_%(c_type)s_members(v, %(c_name)s, &err); ''', c_type=typ.c_name(), c_name=direct_name) + ret += gen_err_check() return ret @@ -63,7 +64,6 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp) if base: ret += gen_visit_members_call(base, '(%s *)obj' % base.c_name()) - ret += gen_err_check() ret += gen_visit_members(members, prefix='obj->') @@ -95,9 +95,9 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp) } ''') - # 'goto out' produced for base, by gen_visit_members() for each member, - # and if variants were present - if base or members or variants: + # 'goto out' produced for non-empty base, by gen_visit_members() for + # each member, and if variants were present + if (base and not base.is_empty()) or members or variants: ret += mcgen(''' out: