From patchwork Sat Feb 20 00:19:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8365261 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 15935C0553 for ; Sat, 20 Feb 2016 00:26:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 764532050E for ; Sat, 20 Feb 2016 00:26:52 +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 BEB3C204DE for ; Sat, 20 Feb 2016 00:26:51 +0000 (UTC) Received: from localhost ([::1]:56574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWvNr-0000Ft-4z for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Feb 2016 19:26:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWvHI-0004pY-9l for qemu-devel@nongnu.org; Fri, 19 Feb 2016 19:20:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWvHF-0003zK-1D for qemu-devel@nongnu.org; Fri, 19 Feb 2016 19:20:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38777) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWvHE-0003z8-RZ for qemu-devel@nongnu.org; Fri, 19 Feb 2016 19:20:00 -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 8C442A84; Sat, 20 Feb 2016 00:20:00 +0000 (UTC) Received: from red.redhat.com (ovpn-113-75.phx2.redhat.com [10.3.113.75]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1K0Jn6U025514; Fri, 19 Feb 2016 19:20:00 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 19 Feb 2016 17:19:43 -0700 Message-Id: <1455927587-28033-14-git-send-email-eblake@redhat.com> In-Reply-To: <1455927587-28033-1-git-send-email-eblake@redhat.com> References: <1455927587-28033-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, Michael Roth Subject: [Qemu-devel] [PATCH 13/17] qapi-visit: Move error check into gen_visit_fields_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=-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 When first introduced, neither branch of gen_visit_fields_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_fields() 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 --- 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 3aca6a7..5d861ba 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -55,6 +55,7 @@ def gen_visit_fields_call(typ, direct_name, implicit_name=None): visit_type_%(c_type)s_fields(v, %(c_name)s, &err); ''', c_type=typ.c_name(), c_name=direct_name) + ret += gen_err_check() return ret @@ -79,7 +80,6 @@ static void visit_type_%(c_name)s_fields(Visitor *v, %(c_name)s *obj, Error **er if base: ret += gen_visit_fields_call(base, '(%s *)obj' % base.c_name()) - ret += gen_err_check() ret += gen_visit_fields(members, prefix='obj->') @@ -111,9 +111,9 @@ static void visit_type_%(c_name)s_fields(Visitor *v, %(c_name)s *obj, Error **er } ''') - # 'goto out' produced for base, by gen_visit_fields() for each member, - # and if variants were present - if base or members or variants: + # 'goto out' produced for non-empty base, by gen_visit_fields() for + # each member, and if variants were present + if (base and not base.is_empty()) or members or variants: ret += mcgen(''' out: