diff options
author | Eric Blake <eblake@redhat.com> | 2016-01-29 06:48:59 -0700 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2016-02-08 17:29:57 +0100 |
commit | 08f9541dec51700abef0c37994213164ca4e4fc9 (patch) | |
tree | 2fbddce86ad35307b616aca8e795965e862b779f | |
parent | bdd8e6b5d8a9def83d491a3f41c10424fc366258 (diff) |
qapi: Drop unused error argument for list and implicit struct
No backend was setting an error when ending the visit of a list or
implicit struct, or when moving to the next list node. 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.
A later patch will then tackle the larger task of splitting
visit_end_struct(), which can indeed set an error.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1454075341-13658-24-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r-- | hw/ppc/spapr_drc.c | 6 | ||||
-rw-r--r-- | include/qapi/visitor-impl.h | 9 | ||||
-rw-r--r-- | include/qapi/visitor.h | 8 | ||||
-rw-r--r-- | qapi/opts-visitor.c | 6 | ||||
-rw-r--r-- | qapi/qapi-dealloc-visitor.c | 8 | ||||
-rw-r--r-- | qapi/qapi-visit-core.c | 12 | ||||
-rw-r--r-- | qapi/qmp-input-visitor.c | 11 | ||||
-rw-r--r-- | qapi/qmp-output-visitor.c | 6 | ||||
-rw-r--r-- | qapi/string-input-visitor.c | 8 | ||||
-rw-r--r-- | qapi/string-output-visitor.c | 8 | ||||
-rw-r--r-- | scripts/qapi-visit.py | 12 |
11 files changed, 41 insertions, 53 deletions
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 1aac6f2f68..ef063c05cf 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -315,11 +315,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 337f99973f..ea252f8e3a 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -24,11 +24,14 @@ 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 */ + GenericList *(*next_list)(Visitor *v, GenericList **list); + /* 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 997555dbd7..5e581dcf7e 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -1,6 +1,7 @@ /* * Core Definitions for QAPI Visitor Classes * + * Copyright (C) 2012-2016 Red Hat, Inc. * Copyright IBM, Corp. 2011 * * Authors: @@ -32,10 +33,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); +GenericList *visit_next_list(Visitor *v, GenericList **list); +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 d1c0c5abf7..d54f75b5e7 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -1,7 +1,7 @@ /* * Options Visitor * - * Copyright Red Hat, Inc. 2012, 2013 + * Copyright Red Hat, Inc. 2012-2016 * * Author: Laszlo Ersek <lersek@redhat.com> * @@ -221,7 +221,7 @@ opts_start_list(Visitor *v, const char *name, Error **errp) static GenericList * -opts_next_list(Visitor *v, GenericList **list, Error **errp) +opts_next_list(Visitor *v, GenericList **list) { OptsVisitor *ov = to_ov(v); GenericList **link; @@ -270,7 +270,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 7c2148dc2e..2659d3fcca 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -1,6 +1,7 @@ /* * Dealloc Visitor * + * Copyright (C) 2012-2016 Red Hat, Inc. * Copyright IBM, Corp. 2011 * * Authors: @@ -84,7 +85,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); @@ -99,8 +100,7 @@ static void qapi_dealloc_start_list(Visitor *v, const char *name, Error **errp) qapi_dealloc_push(qov, NULL); } -static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList **listp, - Error **errp) +static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList **listp) { GenericList *list = *listp; QapiDeallocVisitor *qov = to_qov(v); @@ -120,7 +120,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 2be026c7db..f856286461 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -38,10 +38,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); } } @@ -50,14 +50,14 @@ void visit_start_list(Visitor *v, const char *name, Error **errp) v->start_list(v, name, errp); } -GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp) +GenericList *visit_next_list(Visitor *v, GenericList **list) { - return v->next_list(v, list, errp); + return v->next_list(v, list); } -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 4563c20c13..362a1a33a8 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -1,6 +1,7 @@ /* * Input Visitor * + * Copyright (C) 2012-2016 Red Hat, Inc. * Copyright IBM, Corp. 2011 * * Authors: @@ -154,10 +155,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); @@ -172,8 +169,7 @@ static void qmp_input_start_list(Visitor *v, const char *name, Error **errp) qmp_input_push(qiv, qobj, errp); } -static GenericList *qmp_input_next_list(Visitor *v, GenericList **list, - Error **errp) +static GenericList *qmp_input_next_list(Visitor *v, GenericList **list) { QmpInputVisitor *qiv = to_qiv(v); GenericList *entry; @@ -202,7 +198,7 @@ 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); @@ -353,7 +349,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 ff480a61a3..41f92c8ca9 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -1,6 +1,7 @@ /* * Core Definitions for QAPI/QMP Command Registry * + * Copyright (C) 2012-2016 Red Hat, Inc. * Copyright IBM, Corp. 2011 * * Authors: @@ -136,8 +137,7 @@ static void qmp_output_start_list(Visitor *v, const char *name, Error **errp) qmp_output_push(qov, list); } -static GenericList *qmp_output_next_list(Visitor *v, GenericList **listp, - Error **errp) +static GenericList *qmp_output_next_list(Visitor *v, GenericList **listp) { GenericList *list = *listp; QmpOutputVisitor *qov = to_qov(v); @@ -152,7 +152,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 cdf129cb7d..18b9339768 100644 --- a/qapi/string-input-visitor.c +++ b/qapi/string-input-visitor.c @@ -1,7 +1,7 @@ /* * String parsing visitor * - * Copyright Red Hat, Inc. 2012 + * Copyright Red Hat, Inc. 2012-2016 * * Author: Paolo Bonzini <pbonzini@redhat.com> * @@ -139,8 +139,7 @@ start_list(Visitor *v, const char *name, Error **errp) } } -static GenericList * -next_list(Visitor *v, GenericList **list, Error **errp) +static GenericList *next_list(Visitor *v, GenericList **list) { StringInputVisitor *siv = to_siv(v); GenericList **link; @@ -178,8 +177,7 @@ next_list(Visitor *v, GenericList **list, Error **errp) return *link; } -static void -end_list(Visitor *v, Error **errp) +static void 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 3ce6a3bf67..b980bd3265 100644 --- a/qapi/string-output-visitor.c +++ b/qapi/string-output-visitor.c @@ -1,7 +1,7 @@ /* * String printing Visitor * - * Copyright Red Hat, Inc. 2012 + * Copyright Red Hat, Inc. 2012-2016 * * Author: Paolo Bonzini <pbonzini@redhat.com> * @@ -276,8 +276,7 @@ start_list(Visitor *v, const char *name, Error **errp) sov->head = true; } -static GenericList * -next_list(Visitor *v, GenericList **list, Error **errp) +static GenericList *next_list(Visitor *v, GenericList **list) { StringOutputVisitor *sov = to_sov(v); GenericList *ret = NULL; @@ -303,8 +302,7 @@ next_list(Visitor *v, GenericList **list, Error **errp) return ret; } -static void -end_list(Visitor *v, Error **errp) +static void end_list(Visitor *v) { StringOutputVisitor *sov = to_sov(v); diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 308000fbbe..0fdcebcca8 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); } @@ -161,15 +161,13 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error } for (prev = (GenericList **)obj; - !err && (i = visit_next_list(v, prev, &err)) != NULL; + !err && (i = visit_next_list(v, prev)) != NULL; prev = &i) { %(c_name)s *native_i = (%(c_name)s *)i; 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); } |