diff options
author | Eric Blake <eblake@redhat.com> | 2015-12-01 22:20:52 -0700 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2015-12-17 08:21:29 +0100 |
commit | 5cdc8831a795fb8452d7e34f644202fd724e122a (patch) | |
tree | ed3741502d2d42dfda844d45beedf4307168eaad /qapi | |
parent | d00341af384665d259af475b14c96bb8414df415 (diff) | |
download | qemu-5cdc8831a795fb8452d7e34f644202fd724e122a.zip qemu-5cdc8831a795fb8452d7e34f644202fd724e122a.tar.gz qemu-5cdc8831a795fb8452d7e34f644202fd724e122a.tar.bz2 |
qapi: Simplify visits of optional fields
None of the visitor callbacks would set an error when testing
if an optional field was present; make this part of the interface
contract by eliminating the errp argument.
The resulting generated code has a nice diff:
|- visit_optional(v, &has_fdset_id, "fdset-id", &err);
|- if (err) {
|- goto out;
|- }
|+ visit_optional(v, &has_fdset_id, "fdset-id");
| if (has_fdset_id) {
| visit_type_int(v, &fdset_id, "fdset-id", &err);
| if (err) {
| goto out;
| }
| }
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1449033659-25497-9-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'qapi')
-rw-r--r-- | qapi/opts-visitor.c | 2 | ||||
-rw-r--r-- | qapi/qapi-visit-core.c | 5 | ||||
-rw-r--r-- | qapi/qmp-input-visitor.c | 3 | ||||
-rw-r--r-- | qapi/string-input-visitor.c | 3 |
4 files changed, 5 insertions, 8 deletions
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index cd10392..ef5fb8b 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -488,7 +488,7 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) static void -opts_optional(Visitor *v, bool *present, const char *name, Error **errp) +opts_optional(Visitor *v, bool *present, const char *name) { OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v); diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index cee76bc..e07d6f9 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -73,11 +73,10 @@ void visit_end_union(Visitor *v, bool data_present, Error **errp) } } -void visit_optional(Visitor *v, bool *present, const char *name, - Error **errp) +void visit_optional(Visitor *v, bool *present, const char *name) { if (v->optional) { - v->optional(v, present, name, errp); + v->optional(v, present, name); } } diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index 26b7414..932b5f3 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -303,8 +303,7 @@ static void qmp_input_type_any(Visitor *v, QObject **obj, const char *name, *obj = qobj; } -static void qmp_input_optional(Visitor *v, bool *present, const char *name, - Error **errp) +static void qmp_input_optional(Visitor *v, bool *present, const char *name) { QmpInputVisitor *qiv = to_qiv(v); QObject *qobj = qmp_input_get_object(qiv, name, true); diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c index bbd6a54..dee780a 100644 --- a/qapi/string-input-visitor.c +++ b/qapi/string-input-visitor.c @@ -299,8 +299,7 @@ static void parse_type_number(Visitor *v, double *obj, const char *name, *obj = val; } -static void parse_optional(Visitor *v, bool *present, const char *name, - Error **errp) +static void parse_optional(Visitor *v, bool *present, const char *name) { StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v); |