From patchwork Tue Jan 19 16:10:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8063711 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 CEA0A9F1CC for ; Tue, 19 Jan 2016 16:19:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE75E203DC for ; Tue, 19 Jan 2016 16:19:00 +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 A0746203AC for ; Tue, 19 Jan 2016 16:18:59 +0000 (UTC) Received: from localhost ([::1]:37833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLYzi-0001yK-Tp for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Jan 2016 11:18:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLYs9-0004tO-U3 for qemu-devel@nongnu.org; Tue, 19 Jan 2016 11:11:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLYs3-00025s-6M for qemu-devel@nongnu.org; Tue, 19 Jan 2016 11:11:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45301) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLYs2-00025m-SW; Tue, 19 Jan 2016 11:11:03 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 93E11A3274; Tue, 19 Jan 2016 16:11:02 +0000 (UTC) Received: from red.redhat.com (ovpn-113-211.phx2.redhat.com [10.3.113.211]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0JGAlYW008625; Tue, 19 Jan 2016 11:11:02 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 19 Jan 2016 09:10:26 -0700 Message-Id: <1453219845-30939-19-git-send-email-eblake@redhat.com> In-Reply-To: <1453219845-30939-1-git-send-email-eblake@redhat.com> References: <1453219845-30939-1-git-send-email-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 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 , Alexander Graf , "open list:sPAPR" , marcandre.lureau@redhat.com, David Gibson Subject: [Qemu-devel] [PATCH v9 18/37] qapi: Drop unused error argument for list and 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 No backend was setting an error when ending the visit of a list or implicit struct. Make the callers a bit easier to follow by making this a part of the contract, and removing the errp argument - callers can then unconditionally end an object as part of cleanup without having to think about whether a second error is dominated by a first, because there is no second error. The only addition of &error_abort in this patch, in the function qmp_input_end_list(), will never trigger unless a programming bug creates a push(struct)/pop(list) or push(list)/pop(struct) mismatch. A later patch will then tackle the larger task of splitting visit_end_struct(), which can indeed set an error (and that cleanup will also have the side-effect of removing the use of error_abort added here). Signed-off-by: Eric Blake Reviewed-by: Marc-André Lureau --- v9: enhance commit message v8: no change v7: place earlier in series, rebase to earlier changes v6: new patch, split from RFC on v5 7/46 --- hw/ppc/spapr_drc.c | 6 +----- include/qapi/visitor-impl.h | 6 ++++-- include/qapi/visitor.h | 5 +++-- qapi/opts-visitor.c | 2 +- qapi/qapi-dealloc-visitor.c | 4 ++-- qapi/qapi-visit-core.c | 8 ++++---- qapi/qmp-input-visitor.c | 9 ++------- qapi/qmp-output-visitor.c | 2 +- qapi/string-input-visitor.c | 2 +- qapi/string-output-visitor.c | 2 +- scripts/qapi-visit.py | 10 +++------- 11 files changed, 23 insertions(+), 33 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 78d71e2..ffc2cd9 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -314,11 +314,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name, return; } } - visit_end_list(v, &err); - if (err) { - error_propagate(errp, err); - return; - } + visit_end_list(v); break; } default: diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 6abfda7..7f512cf 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -24,11 +24,13 @@ struct Visitor void (*start_implicit_struct)(Visitor *v, void **obj, size_t size, Error **errp); - void (*end_implicit_struct)(Visitor *v, Error **errp); + /* May be NULL */ + void (*end_implicit_struct)(Visitor *v); void (*start_list)(Visitor *v, const char *name, Error **errp); GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp); - void (*end_list)(Visitor *v, Error **errp); + /* Must be set */ + void (*end_list)(Visitor *v); void (*type_enum)(Visitor *v, const char *name, int *obj, const char *const strings[], Error **errp); diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 4abc180..10390d2 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -32,10 +32,11 @@ void visit_start_struct(Visitor *v, const char *name, void **obj, void visit_end_struct(Visitor *v, Error **errp); void visit_start_implicit_struct(Visitor *v, void **obj, size_t size, Error **errp); -void visit_end_implicit_struct(Visitor *v, Error **errp); +void visit_end_implicit_struct(Visitor *v); + void visit_start_list(Visitor *v, const char *name, Error **errp); GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp); -void visit_end_list(Visitor *v, Error **errp); +void visit_end_list(Visitor *v); /** * Check if an optional member @name of an object needs visiting. diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index 6d4a91e..62ffdd4 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -269,7 +269,7 @@ opts_next_list(Visitor *v, GenericList **list, Error **errp) static void -opts_end_list(Visitor *v, Error **errp) +opts_end_list(Visitor *v) { OptsVisitor *ov = to_ov(v); diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index 49e7cf0..560feb3 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -83,7 +83,7 @@ static void qapi_dealloc_start_implicit_struct(Visitor *v, qapi_dealloc_push(qov, obj); } -static void qapi_dealloc_end_implicit_struct(Visitor *v, Error **errp) +static void qapi_dealloc_end_implicit_struct(Visitor *v) { QapiDeallocVisitor *qov = to_qov(v); void **obj = qapi_dealloc_pop(qov); @@ -119,7 +119,7 @@ static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList **listp, return NULL; } -static void qapi_dealloc_end_list(Visitor *v, Error **errp) +static void qapi_dealloc_end_list(Visitor *v) { QapiDeallocVisitor *qov = to_qov(v); void *obj = qapi_dealloc_pop(qov); diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index b0452cf..2d3743b 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -37,10 +37,10 @@ void visit_start_implicit_struct(Visitor *v, void **obj, size_t size, } } -void visit_end_implicit_struct(Visitor *v, Error **errp) +void visit_end_implicit_struct(Visitor *v) { if (v->end_implicit_struct) { - v->end_implicit_struct(v, errp); + v->end_implicit_struct(v); } } @@ -54,9 +54,9 @@ GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp) return v->next_list(v, list, errp); } -void visit_end_list(Visitor *v, Error **errp) +void visit_end_list(Visitor *v) { - v->end_list(v, errp); + v->end_list(v); } bool visit_start_union(Visitor *v, bool data_present, Error **errp) diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index bf25249..597652c 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -153,10 +153,6 @@ static void qmp_input_start_implicit_struct(Visitor *v, void **obj, } } -static void qmp_input_end_implicit_struct(Visitor *v, Error **errp) -{ -} - static void qmp_input_start_list(Visitor *v, const char *name, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); @@ -201,11 +197,11 @@ static GenericList *qmp_input_next_list(Visitor *v, GenericList **list, return entry; } -static void qmp_input_end_list(Visitor *v, Error **errp) +static void qmp_input_end_list(Visitor *v) { QmpInputVisitor *qiv = to_qiv(v); - qmp_input_pop(qiv, errp); + qmp_input_pop(qiv, &error_abort); } static void qmp_input_get_next_type(Visitor *v, const char *name, QType *type, @@ -352,7 +348,6 @@ QmpInputVisitor *qmp_input_visitor_new(QObject *obj) v->visitor.start_struct = qmp_input_start_struct; v->visitor.end_struct = qmp_input_end_struct; v->visitor.start_implicit_struct = qmp_input_start_implicit_struct; - v->visitor.end_implicit_struct = qmp_input_end_implicit_struct; v->visitor.start_list = qmp_input_start_list; v->visitor.next_list = qmp_input_next_list; v->visitor.end_list = qmp_input_end_list; diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index db5e618..d367148 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -151,7 +151,7 @@ static GenericList *qmp_output_next_list(Visitor *v, GenericList **listp, return list ? list->next : NULL; } -static void qmp_output_end_list(Visitor *v, Error **errp) +static void qmp_output_end_list(Visitor *v) { QmpOutputVisitor *qov = to_qov(v); qmp_output_pop(qov); diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c index 5347b61..610c233 100644 --- a/qapi/string-input-visitor.c +++ b/qapi/string-input-visitor.c @@ -178,7 +178,7 @@ next_list(Visitor *v, GenericList **list, Error **errp) } static void -end_list(Visitor *v, Error **errp) +end_list(Visitor *v) { StringInputVisitor *siv = to_siv(v); siv->head = true; diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c index 74de6b6..fd917a4 100644 --- a/qapi/string-output-visitor.c +++ b/qapi/string-output-visitor.c @@ -303,7 +303,7 @@ next_list(Visitor *v, GenericList **list, Error **errp) } static void -end_list(Visitor *v, Error **errp) +end_list(Visitor *v) { StringOutputVisitor *sov = to_sov(v); diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 8a741b6..573bb81 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -62,7 +62,7 @@ static void visit_type_implicit_%(c_type)s(Visitor *v, %(c_type)s **obj, Error * 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, &err); + visit_end_implicit_struct(v); } error_propagate(errp, err); } @@ -167,9 +167,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error visit_type_%(c_elt_type)s(v, NULL, &native_i->value, &err); } - error_propagate(errp, err); - err = NULL; - visit_end_list(v, &err); + visit_end_list(v); out: error_propagate(errp, err); } @@ -230,9 +228,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error "%(name)s"); } out_obj: - error_propagate(errp, err); - err = NULL; - visit_end_implicit_struct(v, &err); + visit_end_implicit_struct(v); out: error_propagate(errp, err); }