From patchwork Wed Jan 27 13:54:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8134371 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 DFB21BEEE5 for ; Wed, 27 Jan 2016 14:14:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B019202EB for ; Wed, 27 Jan 2016 14:14:20 +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 7E76820145 for ; Wed, 27 Jan 2016 14:14:15 +0000 (UTC) Received: from localhost ([::1]:50658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQZ1-0007dX-4z for patchwork-qemu-devel@patchwork.kernel.org; Wed, 27 Jan 2016 08:55:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQYi-0007OT-IZ for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:55:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOQYe-0002lN-Oj for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:54:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQYe-0002kt-Jr for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:54:52 -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 E4C27C0B66D3; Wed, 27 Jan 2016 13:54:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-52.phx2.redhat.com [10.3.113.52]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0RDsnS7001935 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 27 Jan 2016 08:54:50 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9C70C3011F90; Wed, 27 Jan 2016 14:54:48 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 27 Jan 2016 14:54:47 +0100 Message-Id: <1453902888-20457-3-git-send-email-armbru@redhat.com> In-Reply-To: <1453902888-20457-1-git-send-email-armbru@redhat.com> References: <1453219845-30939-27-git-send-email-eblake@redhat.com> <1453902888-20457-1-git-send-email-armbru@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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 2/3] qapi-visit: Clean up code generated around visit_end_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+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 The generated code can call visit_end_union() without having called visit_start_union(). Example: if (!*obj) { goto out_obj; } visit_type_BlockdevOptions_fields(v, obj, &err); if (err) { goto out_obj; // if we go from here... } if (!visit_start_union(v, !!(*obj)->u.data, &err) || err) { goto out_obj; } switch ((*obj)->driver) { [...] } out_obj: // ... then *obj is true, and ... error_propagate(errp, err); err = NULL; if (*obj) { // we end up here visit_end_union(v, !!(*obj)->u.data, &err); } error_propagate(errp, err); Harmless only because no visitor implements end_union(). Clean it up anyway. Messed up since we have visit_end_union (commit cee2ded). Signed-off-by: Markus Armbruster --- scripts/qapi-visit.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 5c0d4d2..8dcc6dc 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -299,12 +299,10 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error default: abort(); } -out_obj: error_propagate(errp, err); err = NULL; - if (*obj) { - visit_end_union(v, !!(*obj)->u.data, &err); - } + visit_end_union(v, !!(*obj)->u.data, &err); +out_obj: error_propagate(errp, err); err = NULL; visit_end_struct(v, &err);