mirror of
https://github.com/mii443/qemu.git
synced 2025-08-31 11:29:26 +00:00
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>
This commit is contained in:
committed by
Markus Armbruster
parent
5cdc8831a7
commit
29637a6ee9
@ -1656,8 +1656,7 @@ def gen_visit_fields(members, prefix='', need_cast=False, skiperr=False):
|
||||
for memb in members:
|
||||
if memb.optional:
|
||||
ret += mcgen('''
|
||||
visit_optional(v, &%(prefix)shas_%(c_name)s, "%(name)s");
|
||||
if (%(prefix)shas_%(c_name)s) {
|
||||
if (visit_optional(v, &%(prefix)shas_%(c_name)s, "%(name)s")) {
|
||||
''',
|
||||
prefix=prefix, c_name=c_name(memb.name),
|
||||
name=memb.name, errp=errparg)
|
||||
|
Reference in New Issue
Block a user