mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-28 21:03:54 -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
|
@ -81,11 +81,9 @@ static void visit_type_%(c_name)s_fields(Visitor *v, %(c_name)s **obj, Error **e
|
|||
if base:
|
||||
ret += mcgen('''
|
||||
visit_type_implicit_%(c_type)s(v, &(*obj)->%(c_name)s, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
''',
|
||||
c_type=base.c_name(), c_name=c_name('base'))
|
||||
ret += gen_err_check()
|
||||
|
||||
for memb in members:
|
||||
if memb.optional:
|
||||
|
@ -107,11 +105,7 @@ static void visit_type_%(c_name)s_fields(Visitor *v, %(c_name)s **obj, Error **e
|
|||
ret += mcgen('''
|
||||
}
|
||||
''')
|
||||
ret += mcgen('''
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
''')
|
||||
ret += gen_err_check()
|
||||
|
||||
if re.search('^ *goto out;', ret, re.MULTILINE):
|
||||
ret += mcgen('''
|
||||
|
@ -271,11 +265,9 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
|
|||
if base:
|
||||
ret += mcgen('''
|
||||
visit_type_%(c_name)s_fields(v, obj, &err);
|
||||
if (err) {
|
||||
goto out_obj;
|
||||
}
|
||||
''',
|
||||
c_name=c_name(name))
|
||||
ret += gen_err_check(label='out_obj')
|
||||
|
||||
tag_key = variants.tag_member.name
|
||||
if not variants.tag_name:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue