aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/qapi/visitor-impl.h5
-rw-r--r--include/qapi/visitor.h5
-rw-r--r--qapi/opts-visitor.c5
-rw-r--r--qapi/qapi-visit-core.c15
-rw-r--r--qapi/qmp-input-visitor.c6
-rw-r--r--qapi/string-input-visitor.c6
-rw-r--r--scripts/qapi-commands.py5
-rw-r--r--scripts/qapi-visit.py3
8 files changed, 19 insertions, 31 deletions
diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index 166aaddd29..ecc0183196 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -42,9 +42,8 @@ struct Visitor
Error **errp);
/* May be NULL */
- void (*start_optional)(Visitor *v, bool *present, const char *name,
- Error **errp);
- void (*end_optional)(Visitor *v, Error **errp);
+ void (*optional)(Visitor *v, bool *present, const char *name,
+ Error **errp);
void (*type_uint8)(Visitor *v, uint8_t *obj, const char *name, Error **errp);
void (*type_uint16)(Visitor *v, uint16_t *obj, const char *name, Error **errp);
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 29da211b47..4a0178fa46 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -39,9 +39,8 @@ void visit_end_implicit_struct(Visitor *v, Error **errp);
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_start_optional(Visitor *v, bool *present, const char *name,
- Error **errp);
-void visit_end_optional(Visitor *v, Error **errp);
+void visit_optional(Visitor *v, bool *present, const char *name,
+ Error **errp);
void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,
const char *name, Error **errp);
void visit_type_enum(Visitor *v, int *obj, const char *strings[],
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 87c1c789c9..16382e7a65 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -484,8 +484,7 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
static void
-opts_start_optional(Visitor *v, bool *present, const char *name,
- Error **errp)
+opts_optional(Visitor *v, bool *present, const char *name, Error **errp)
{
OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
@@ -528,7 +527,7 @@ opts_visitor_new(const QemuOpts *opts)
/* type_number() is not filled in, but this is not the first visitor to
* skip some mandatory methods... */
- ov->visitor.start_optional = &opts_start_optional;
+ ov->visitor.optional = &opts_optional;
ov->opts_root = opts;
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 1f7475c0f3..ffd76372d1 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -69,18 +69,11 @@ void visit_end_list(Visitor *v, Error **errp)
v->end_list(v, errp);
}
-void visit_start_optional(Visitor *v, bool *present, const char *name,
- Error **errp)
+void visit_optional(Visitor *v, bool *present, const char *name,
+ Error **errp)
{
- if (!error_is_set(errp) && v->start_optional) {
- v->start_optional(v, present, name, errp);
- }
-}
-
-void visit_end_optional(Visitor *v, Error **errp)
-{
- if (!error_is_set(errp) && v->end_optional) {
- v->end_optional(v, errp);
+ if (!error_is_set(errp) && v->optional) {
+ v->optional(v, present, name, errp);
}
}
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index a2bed1ef10..d8612062f1 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -286,8 +286,8 @@ static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
}
}
-static void qmp_input_start_optional(Visitor *v, bool *present,
- const char *name, Error **errp)
+static void qmp_input_optional(Visitor *v, bool *present, const char *name,
+ Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true);
@@ -329,7 +329,7 @@ QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
v->visitor.type_bool = qmp_input_type_bool;
v->visitor.type_str = qmp_input_type_str;
v->visitor.type_number = qmp_input_type_number;
- v->visitor.start_optional = qmp_input_start_optional;
+ v->visitor.optional = qmp_input_optional;
v->visitor.get_next_type = qmp_input_get_next_type;
qmp_input_push(v, obj, NULL);
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 793548ae3a..5780944792 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -120,8 +120,8 @@ static void parse_type_number(Visitor *v, double *obj, const char *name,
*obj = val;
}
-static void parse_start_optional(Visitor *v, bool *present,
- const char *name, Error **errp)
+static void parse_optional(Visitor *v, bool *present, const char *name,
+ Error **errp)
{
StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
@@ -155,7 +155,7 @@ StringInputVisitor *string_input_visitor_new(const char *str)
v->visitor.type_bool = parse_type_bool;
v->visitor.type_str = parse_type_str;
v->visitor.type_number = parse_type_number;
- v->visitor.start_optional = parse_start_optional;
+ v->visitor.optional = parse_optional;
v->string = str;
return v;
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 1399826cca..341dba27a8 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -131,7 +131,7 @@ v = qmp_input_get_visitor(mi);
for argname, argtype, optional, structured in parse_args(args):
if optional:
ret += mcgen('''
-visit_start_optional(v, &has_%(c_name)s, "%(name)s", %(errp)s);
+visit_optional(v, &has_%(c_name)s, "%(name)s", %(errp)s);
if (has_%(c_name)s) {
''',
c_name=c_var(argname), name=argname, errp=errparg)
@@ -145,8 +145,7 @@ if (has_%(c_name)s) {
pop_indent()
ret += mcgen('''
}
-visit_end_optional(v, %(errp)s);
-''', errp=errparg)
+''')
if dealloc:
ret += mcgen('''
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index c6579beed5..9f22eee873 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -61,7 +61,7 @@ if (!err) {
for argname, argentry, optional, structured in parse_args(members):
if optional:
ret += mcgen('''
-visit_start_optional(m, &(*obj)->%(c_prefix)shas_%(c_name)s, "%(name)s", &err);
+visit_optional(m, &(*obj)->%(c_prefix)shas_%(c_name)s, "%(name)s", &err);
if ((*obj)->%(prefix)shas_%(c_name)s) {
''',
c_prefix=c_var(field_prefix), prefix=field_prefix,
@@ -82,7 +82,6 @@ visit_type_%(type)s(m, &(*obj)->%(c_prefix)s%(c_name)s, "%(name)s", &err);
pop_indent()
ret += mcgen('''
}
-visit_end_optional(m, &err);
''')
pop_indent()