summaryrefslogtreecommitdiffstats
path: root/include/qapi/visitor.h
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-12-01 22:20:53 -0700
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:19 -0600
commita1f6056b9b3c027166263ca9f66b279bce430ca5 (patch)
tree8e88a02d7dace73d19b8e7af0d8afceb13048050 /include/qapi/visitor.h
parent1e741644ef4d9926705d251d6992f7e575a277f3 (diff)
downloadhqemu-a1f6056b9b3c027166263ca9f66b279bce430ca5.zip
hqemu-a1f6056b9b3c027166263ca9f66b279bce430ca5.tar.gz
qapi: Shorter visits of optional fields
For less code, reflect the determined boolean value of an optional visit back to the caller instead of making the caller read the boolean after the fact. The resulting generated code has the following diff: |- visit_optional(v, &has_fdset_id, "fdset-id"); |- if (has_fdset_id) { |+ if (visit_optional(v, &has_fdset_id, "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-10-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/qapi/visitor.h')
-rw-r--r--include/qapi/visitor.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 9be60d4..a14a16d 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -41,9 +41,9 @@ void visit_end_list(Visitor *v, Error **errp);
* Check if an optional member @name of an object needs visiting.
* For input visitors, set *@present according to whether the
* corresponding visit_type_*() needs calling; for other visitors,
- * leave *@present unchanged.
+ * leave *@present unchanged. Return *@present for convenience.
*/
-void visit_optional(Visitor *v, bool *present, const char *name);
+bool visit_optional(Visitor *v, bool *present, const char *name);
/**
* Determine the qtype of the item @name in the current object visit.
OpenPOWER on IntegriCloud