aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi-commands.py
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-09-29 16:21:13 -0600
committerMarkus Armbruster <armbru@redhat.com>2015-10-12 18:46:50 +0200
commit1f35334489a43800df4d20cd91362a87cee39a29 (patch)
tree8cb5cea8f18e493525e5a8908e109b705b6b1d6e /scripts/qapi-commands.py
parent05372f708a8cb3556e4d67458de79417dadf241f (diff)
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>
Diffstat (limited to 'scripts/qapi-commands.py')
-rw-r--r--scripts/qapi-commands.py17
1 files changed, 3 insertions, 14 deletions
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 267991ed8b..4e99c1de8b 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -25,17 +25,6 @@ def gen_command_decl(name, arg_type, ret_type):
params=gen_params(arg_type, 'Error **errp'))
-def gen_err_check(err):
- if not err:
- return ''
- return mcgen('''
- if (%(err)s) {
- goto out;
- }
-''',
- err=err)
-
-
def gen_call(name, arg_type, ret_type):
ret = ''
@@ -56,7 +45,7 @@ def gen_call(name, arg_type, ret_type):
''',
c_name=c_name(name), args=argstr, lhs=lhs)
if ret_type:
- ret += gen_err_check('err')
+ ret += gen_err_check()
ret += mcgen('''
qmp_marshal_output_%(c_name)s(retval, ret, &err);
@@ -133,7 +122,7 @@ def gen_marshal_input_visit(arg_type, dealloc=False):
''',
c_name=c_name(memb.name), name=memb.name,
errp=errparg)
- ret += gen_err_check(errarg)
+ ret += gen_err_check(err=errarg)
ret += mcgen('''
if (has_%(c_name)s) {
''',
@@ -144,7 +133,7 @@ def gen_marshal_input_visit(arg_type, dealloc=False):
''',
c_name=c_name(memb.name), name=memb.name,
c_type=memb.type.c_name(), errp=errparg)
- ret += gen_err_check(errarg)
+ ret += gen_err_check(err=errarg)
if memb.optional:
pop_indent()
ret += mcgen('''