[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 08/23] qapi: Drop unused error argument for list
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v6 08/23] qapi: Drop unused error argument for list and implicit struct |
Date: |
Wed, 25 Nov 2015 17:23:05 -0700 |
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.
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 <address@hidden>
---
v6: new patch, split from RFC on v5 7/46
---
hw/ppc/spapr_drc.c | 2 +-
include/qapi/visitor-impl.h | 4 ++--
include/qapi/visitor.h | 8 +++++---
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(+), 30 deletions(-)
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index f34bc04..1846b4f 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -293,7 +293,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, void
*opaque,
visit_type_uint8(v, (uint8_t *)&prop->data[i], NULL, NULL);
}
- visit_end_list(v, NULL);
+ visit_end_list(v);
break;
}
default:
diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index 2f4c89b..36984a7 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -35,14 +35,14 @@ struct Visitor
void (*start_implicit_struct)(Visitor *v, void **obj, size_t size,
Error **errp);
/* May be NULL */
- void (*end_implicit_struct)(Visitor *v, Error **errp);
+ void (*end_implicit_struct)(Visitor *v);
/* Must be set */
void (*start_list)(Visitor *v, const char *name, Error **errp);
/* Must be set */
GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
/* Must be set */
- void (*end_list)(Visitor *v, Error **errp);
+ void (*end_list)(Visitor *v);
/* Must be set, although the helpers input_type_enum() and
* output_type_enum() can be used. */
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 74159c6..b4ed469 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -77,9 +77,11 @@ void visit_start_implicit_struct(Visitor *v, void **obj,
size_t size,
/**
* Complete an implicit struct visit started earlier.
* Must be called after any successful use of visit_start_implicit_struct(),
- * even if intermediate processing was skipped due to errors.
+ * even if intermediate processing was skipped due to errors. Unlike
+ * visit_end_struct(), there is no need for an error check; any errors
+ * such as extra input will be detected when ending the overall struct.
*/
-void visit_end_implicit_struct(Visitor *v, Error **errp);
+void visit_end_implicit_struct(Visitor *v);
/**
* Prepare to visit a list tied to an object key @name.
@@ -105,7 +107,7 @@ GenericList *visit_next_list(Visitor *v, GenericList
**list, Error **errp);
* even if intermediate processing was skipped due to errors, to allow
* the backend to release any resources.
*/
-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 8104e42..37f172d 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -263,7 +263,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 = DO_UPCAST(OptsVisitor, visitor, v);
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index 5133d37..8246070 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -85,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);
@@ -121,7 +121,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 be1fcdd..477d73a 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -36,10 +36,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);
}
}
@@ -53,9 +53,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 ba743db..9ff1e75 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, QType *type, bool promote_int,
@@ -351,7 +347,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 4a28ce3..8035649 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -153,7 +153,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 0a7ddee..5b2bc47 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -173,7 +173,7 @@ next_list(Visitor *v, GenericList **list, Error **errp)
}
static void
-end_list(Visitor *v, Error **errp)
+end_list(Visitor *v)
{
StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
siv->head = true;
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index bcd72bb..54d4174 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -298,7 +298,7 @@ next_list(Visitor *v, GenericList **list, Error **errp)
}
static void
-end_list(Visitor *v, Error **errp)
+end_list(Visitor *v)
{
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index ddfb769..8c964b5 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,9 +161,7 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj,
const char *name, Error
visit_type_%(c_elt_type)s(v, &native_i->value, NULL, &err);
}
- error_propagate(errp, err);
- err = NULL;
- visit_end_list(v, &err);
+ visit_end_list(v);
out:
error_propagate(errp, err);
}
@@ -224,9 +222,7 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj,
const char *name, 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);
}
--
2.4.3
- [Qemu-devel] [PATCH v6 10/23] vl: Improve use of qapi visitor, (continued)
- [Qemu-devel] [PATCH v6 10/23] vl: Improve use of qapi visitor, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 13/23] qapi: Add type.is_empty() helper, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 15/23] qapi: Improve generated event use of qapi visitor, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 19/23] qapi-visit: Unify struct and union visit, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 18/23] qapi: Canonicalize missing object to :empty, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 23/23] qapi: Change visit_type_FOO() to no longer return partial objects, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 22/23] qapi: Split visit_end_struct() into pieces, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 12/23] balloon: Improve use of qapi visitor, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 07/23] qapi: Document visitor interfaces, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 17/23] qapi: Eliminate empty visit_type_FOO_fields, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 08/23] qapi: Drop unused error argument for list and implicit struct,
Eric Blake <=
- [Qemu-devel] [PATCH v6 21/23] qapi: Simplify extra member error reporting in input visitors, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 20/23] qapi: Rework deallocation of partial struct, Eric Blake, 2015/11/25