mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qapi: Share gen_err_check()
qapi-commands has a nice helper gen_err_check(), but did not use it everywhere. In fact, using it in more places makes it easier to reduce the lines of code used for generating error checks. This in turn will make it easier for later patches to consolidate another common pattern among the generators. The generated code has fewer blank lines in qapi-event.c functions, but has no semantic difference. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1443565276-4535-16-git-send-email-eblake@redhat.com> [Drop another blank line for symmetry] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
05372f708a
commit
1f35334489
4 changed files with 20 additions and 33 deletions
|
@ -68,12 +68,9 @@ def gen_event_send(name, arg_type):
|
|||
|
||||
/* Fake visit, as if all members are under a structure */
|
||||
visit_start_struct(v, NULL, "", "%(name)s", 0, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
''',
|
||||
name=name)
|
||||
ret += gen_err_check()
|
||||
|
||||
for memb in arg_type.members:
|
||||
if memb.optional:
|
||||
|
@ -91,14 +88,12 @@ def gen_event_send(name, arg_type):
|
|||
|
||||
ret += mcgen('''
|
||||
visit_type_%(c_type)s(v, %(cast)s&%(c_name)s, "%(name)s", &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
''',
|
||||
cast=cast,
|
||||
c_name=c_name(memb.name),
|
||||
c_type=memb.type.c_name(),
|
||||
name=memb.name)
|
||||
ret += gen_err_check()
|
||||
|
||||
if memb.optional:
|
||||
pop_indent()
|
||||
|
@ -107,7 +102,6 @@ def gen_event_send(name, arg_type):
|
|||
''')
|
||||
|
||||
ret += mcgen('''
|
||||
|
||||
visit_end_struct(v, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue