From patchwork Thu Feb 18 06:48:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8346581 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 88618C0553 for ; Thu, 18 Feb 2016 06:49:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C038C20395 for ; Thu, 18 Feb 2016 06:49:06 +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 C974020386 for ; Thu, 18 Feb 2016 06:49:05 +0000 (UTC) Received: from localhost ([::1]:37637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWIOe-0005g2-9e for patchwork-qemu-devel@patchwork.kernel.org; Thu, 18 Feb 2016 01:49:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWIOI-0005PF-Am for qemu-devel@nongnu.org; Thu, 18 Feb 2016 01:48:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWIOG-00022K-Ti for qemu-devel@nongnu.org; Thu, 18 Feb 2016 01:48:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWIOG-00021w-Jd for qemu-devel@nongnu.org; Thu, 18 Feb 2016 01:48:40 -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 2FD39804F0; Thu, 18 Feb 2016 06:48:40 +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 u1I6mXAj023855; Thu, 18 Feb 2016 01:48:39 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 17 Feb 2016 23:48:28 -0700 Message-Id: <1455778109-6278-15-git-send-email-eblake@redhat.com> In-Reply-To: <1455778109-6278-1-git-send-email-eblake@redhat.com> References: <1455778109-6278-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 v11 14/15] qapi: Delete visit_start_union(), gen_visit_implicit_struct() 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 Delete code rendered dead in the previous patch. As explained there, we no longer have any need to use visit_start_struct(), and we no longer have any more code trying to create or use visit_type_implicit_FOO(). Signed-off-by: Eric Blake --- v11: retitle, merge multiple cleanups, avoid bisection bug by hoisting visit_start_union() hunk to patch where it matters v10: retitle, hoist earlier in series, rebase, drop R-b v9: no change v8: rebase to 'name' motion v7: rebase to earlier context changes, simplify 'obj && !*obj' condition based on contract v6: rebase due to deferring 7/46, and gen_err_check() improvements; rewrite gen_visit_implicit_struct() more like other patterns --- include/qapi/visitor.h | 1 - include/qapi/visitor-impl.h | 2 -- scripts/qapi-visit.py | 29 ----------------------------- qapi/qapi-visit-core.c | 8 -------- qapi/qapi-dealloc-visitor.c | 26 -------------------------- 5 files changed, 66 deletions(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 8a2d5cc..a6678b1 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -79,6 +79,5 @@ void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp); void visit_type_number(Visitor *v, const char *name, double *obj, Error **errp); void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp); -bool visit_start_union(Visitor *v, bool data_present, Error **errp); #endif diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 7905a28..c4af3e0 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -58,8 +58,6 @@ struct Visitor /* May be NULL; most useful for input visitors. */ void (*optional)(Visitor *v, const char *name, bool *present); - - bool (*start_union)(Visitor *v, bool data_present, Error **errp); }; void input_type_enum(Visitor *v, const char *name, int *obj, diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 367c459..d2c2dc0 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -15,10 +15,6 @@ from qapi import * import re -# visit_type_FOO_implicit() is emitted as needed; track if it has already -# been output. -implicit_structs_seen = set() - # visit_type_FOO_fields() is always emitted; track if a forward declaration # or implementation has already been output. struct_fields_seen = set() @@ -45,31 +41,6 @@ static void visit_type_%(c_type)s_fields(Visitor *v, %(c_type)s *obj, Error **er c_type=typ.c_name()) -def gen_visit_implicit_struct(typ): - if typ in implicit_structs_seen: - return '' - implicit_structs_seen.add(typ) - - ret = gen_visit_fields_decl(typ) - - ret += mcgen(''' - -static void visit_type_implicit_%(c_type)s(Visitor *v, %(c_type)s **obj, Error **errp) -{ - Error *err = NULL; - - visit_start_implicit_struct(v, (void **)obj, sizeof(%(c_type)s), &err); - if (!err) { - visit_type_%(c_type)s_fields(v, *obj, errp); - visit_end_implicit_struct(v); - } - error_propagate(errp, err); -} -''', - c_type=typ.c_name()) - return ret - - def gen_visit_struct_fields(name, base, members, variants=None): ret = '' diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index b4a0f21..f7b9980 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -61,14 +61,6 @@ void visit_end_list(Visitor *v) v->end_list(v); } -bool visit_start_union(Visitor *v, bool data_present, Error **errp) -{ - if (v->start_union) { - return v->start_union(v, data_present, errp); - } - return true; -} - bool visit_optional(Visitor *v, const char *name, bool *present) { if (v->optional) { diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index 6667e8c..4eae555 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -169,31 +169,6 @@ static void qapi_dealloc_type_enum(Visitor *v, const char *name, int *obj, { } -/* If there's no data present, the dealloc visitor has nothing to free. - * Thus, indicate to visitor code that the subsequent union fields can - * be skipped. This is not an error condition, since the cleanup of the - * rest of an object can continue unhindered, so leave errp unset in - * these cases. - * - * NOTE: In cases where we're attempting to deallocate an object that - * may have missing fields, the field indicating the union type may - * be missing. In such a case, it's possible we don't have enough - * information to differentiate data_present == false from a case where - * data *is* present but happens to be a scalar with a value of 0. - * This is okay, since in the case of the dealloc visitor there's no - * work that needs to done in either situation. - * - * The current inability in QAPI code to more thoroughly verify a union - * type in such cases will likely need to be addressed if we wish to - * implement this interface for other types of visitors in the future, - * however. - */ -static bool qapi_dealloc_start_union(Visitor *v, bool data_present, - Error **errp) -{ - return data_present; -} - Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v) { return &v->visitor; @@ -224,7 +199,6 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void) v->visitor.type_str = qapi_dealloc_type_str; v->visitor.type_number = qapi_dealloc_type_number; v->visitor.type_any = qapi_dealloc_type_anything; - v->visitor.start_union = qapi_dealloc_start_union; QTAILQ_INIT(&v->stack);