diff options
author | Eric Blake <eblake@redhat.com> | 2015-09-29 16:21:08 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2015-10-12 18:46:49 +0200 |
commit | 2a0f50e8d973b01eda4c63bac4a5c79ea0f584ef (patch) | |
tree | 0b06661adc5bcf9f9c57cea9e3eb28cb7a5532aa | |
parent | 376863ef4895ae709aadb6f26365a5973310ef09 (diff) | |
download | qemu-2a0f50e8d973b01eda4c63bac4a5c79ea0f584ef.zip qemu-2a0f50e8d973b01eda4c63bac4a5c79ea0f584ef.tar.gz qemu-2a0f50e8d973b01eda4c63bac4a5c79ea0f584ef.tar.bz2 |
qapi: Consistent generated code: prefer error 'err'
We had some pointless differences in the generated code for visit,
command marshalling, and events; unifying them makes it easier for
future patches to consolidate to common helper functions.
This is one patch of a series to clean up these differences.
This patch consistently names the local error variable 'err' rather
than 'local_err'.
No change in semantics to the generated code.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1443565276-4535-11-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r-- | docs/qapi-code-gen.txt | 28 | ||||
-rw-r--r-- | scripts/qapi-commands.py | 22 | ||||
-rw-r--r-- | scripts/qapi-event.py | 18 |
3 files changed, 34 insertions, 34 deletions
diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index b1c8361..b99e6fa 100644 --- a/docs/qapi-code-gen.txt +++ b/docs/qapi-code-gen.txt @@ -916,20 +916,20 @@ Example: static void qmp_marshal_output_UserDefOne(UserDefOne *ret_in, QObject **ret_out, Error **errp) { - Error *local_err = NULL; + Error *err = NULL; QmpOutputVisitor *mo = qmp_output_visitor_new(); QapiDeallocVisitor *md; Visitor *v; v = qmp_output_get_visitor(mo); - visit_type_UserDefOne(v, &ret_in, "unused", &local_err); - if (local_err) { + visit_type_UserDefOne(v, &ret_in, "unused", &err); + if (err) { goto out; } *ret_out = qmp_output_get_qobject(mo); out: - error_propagate(errp, local_err); + error_propagate(errp, err); qmp_output_visitor_cleanup(mo); md = qapi_dealloc_visitor_new(); v = qapi_dealloc_get_visitor(md); @@ -939,7 +939,7 @@ Example: static void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp) { - Error *local_err = NULL; + Error *err = NULL; UserDefOne *retval; QmpInputVisitor *mi = qmp_input_visitor_new_strict(QOBJECT(args)); QapiDeallocVisitor *md; @@ -947,20 +947,20 @@ Example: UserDefOne *arg1 = NULL; v = qmp_input_get_visitor(mi); - visit_type_UserDefOne(v, &arg1, "arg1", &local_err); - if (local_err) { + visit_type_UserDefOne(v, &arg1, "arg1", &err); + if (err) { goto out; } - retval = qmp_my_command(arg1, &local_err); - if (local_err) { + retval = qmp_my_command(arg1, &err); + if (err) { goto out; } - qmp_marshal_output_UserDefOne(retval, ret, &local_err); + qmp_marshal_output_UserDefOne(retval, ret, &err); out: - error_propagate(errp, local_err); + error_propagate(errp, err); qmp_input_visitor_cleanup(mi); md = qapi_dealloc_visitor_new(); v = qapi_dealloc_get_visitor(md); @@ -1007,7 +1007,7 @@ Example: void qapi_event_send_my_event(Error **errp) { QDict *qmp; - Error *local_err = NULL; + Error *err = NULL; QMPEventFuncEmit emit; emit = qmp_event_get_func_emit(); if (!emit) { @@ -1016,9 +1016,9 @@ Example: qmp = qmp_event_build_dict("MY_EVENT"); - emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp, &local_err); + emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp, &err); - error_propagate(errp, local_err); + error_propagate(errp, err); QDECREF(qmp); } diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index 810a897..2151120 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -53,14 +53,14 @@ def gen_call(name, arg_type, ret_type): push_indent() ret = mcgen(''' -%(lhs)sqmp_%(c_name)s(%(args)s&local_err); +%(lhs)sqmp_%(c_name)s(%(args)s&err); ''', c_name=c_name(name), args=argstr, lhs=lhs) if ret_type: - ret += gen_err_check('local_err') + ret += gen_err_check('err') ret += mcgen(''' -qmp_marshal_output_%(c_name)s(retval, ret, &local_err); +qmp_marshal_output_%(c_name)s(retval, ret, &err); ''', c_name=ret_type.c_name()) pop_indent() @@ -69,7 +69,7 @@ qmp_marshal_output_%(c_name)s(retval, ret, &local_err); def gen_marshal_vars(arg_type, ret_type): ret = mcgen(''' - Error *local_err = NULL; + Error *err = NULL; ''') push_indent() @@ -127,8 +127,8 @@ md = qapi_dealloc_visitor_new(); v = qapi_dealloc_get_visitor(md); ''') else: - errparg = '&local_err' - errarg = 'local_err' + errparg = '&err' + errarg = 'err' ret += mcgen(''' v = qmp_input_get_visitor(mi); ''') @@ -171,20 +171,20 @@ def gen_marshal_output(ret_type): static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, Error **errp) { - Error *local_err = NULL; + Error *err = NULL; QmpOutputVisitor *mo = qmp_output_visitor_new(); QapiDeallocVisitor *md; Visitor *v; v = qmp_output_get_visitor(mo); - visit_type_%(c_name)s(v, &ret_in, "unused", &local_err); - if (local_err) { + visit_type_%(c_name)s(v, &ret_in, "unused", &err); + if (err) { goto out; } *ret_out = qmp_output_get_qobject(mo); out: - error_propagate(errp, local_err); + error_propagate(errp, err); qmp_output_visitor_cleanup(mo); md = qapi_dealloc_visitor_new(); v = qapi_dealloc_get_visitor(md); @@ -227,7 +227,7 @@ def gen_marshal(name, arg_type, ret_type): out: ''') ret += mcgen(''' - error_propagate(errp, local_err); + error_propagate(errp, err); ''') ret += gen_marshal_input_visit(arg_type, dealloc=True) ret += mcgen(''' diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index d15fad9..d41af40 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -34,7 +34,7 @@ def gen_event_send(name, arg_type): %(proto)s { QDict *qmp; - Error *local_err = NULL; + Error *err = NULL; QMPEventFuncEmit emit; ''', proto=gen_event_send_proto(name, arg_type)) @@ -67,8 +67,8 @@ def gen_event_send(name, arg_type): g_assert(v); /* Fake visit, as if all members are under a structure */ - visit_start_struct(v, NULL, "", "%(name)s", 0, &local_err); - if (local_err) { + visit_start_struct(v, NULL, "", "%(name)s", 0, &err); + if (err) { goto clean; } @@ -90,8 +90,8 @@ def gen_event_send(name, arg_type): cast = '' ret += mcgen(''' - visit_type_%(c_type)s(v, %(cast)s&%(c_name)s, "%(name)s", &local_err); - if (local_err) { + visit_type_%(c_type)s(v, %(cast)s&%(c_name)s, "%(name)s", &err); + if (err) { goto clean; } ''', @@ -108,8 +108,8 @@ def gen_event_send(name, arg_type): ret += mcgen(''' - visit_end_struct(v, &local_err); - if (local_err) { + visit_end_struct(v, &err); + if (err) { goto clean; } @@ -120,7 +120,7 @@ def gen_event_send(name, arg_type): ''') ret += mcgen(''' - emit(%(c_enum)s, qmp, &local_err); + emit(%(c_enum)s, qmp, &err); ''', c_enum=c_enum_const(event_enum_name, name)) @@ -131,7 +131,7 @@ def gen_event_send(name, arg_type): qmp_output_visitor_cleanup(qov); ''') ret += mcgen(''' - error_propagate(errp, local_err); + error_propagate(errp, err); QDECREF(qmp); } ''') |