bool visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp)
{
- Error *err = NULL;
-
if (!visit_type_int(v, "integer", &obj->integer, errp)) {
return false;
}
return false;
}
}
- error_propagate(errp, err);
- return !err;
+ return true;
}
bool visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
if (!visit_start_struct(v, name, (void **)obj, sizeof(UserDefOne), errp)) {
return false;
assert(visit_is_dealloc(v));
goto out_obj;
}
- visit_type_UserDefOne_members(v, *obj, &err);
- if (err) {
+ if (!visit_type_UserDefOne_members(v, *obj, errp)) {
goto out_obj;
}
- visit_check_struct(v, &err);
+ ok = visit_check_struct(v, errp);
out_obj:
visit_end_struct(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_UserDefOne(*obj);
*obj = NULL;
}
- error_propagate(errp, err);
- return !err;
+ return ok;
}
bool visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
UserDefOneList *tail;
size_t size = sizeof(**obj);
for (tail = *obj; tail;
tail = (UserDefOneList *)visit_next_list(v, (GenericList *)tail, size)) {
- visit_type_UserDefOne(v, NULL, &tail->value, &err);
- if (err) {
- break;
+ if (!visit_type_UserDefOne(v, NULL, &tail->value, errp)) {
+ goto out_obj;
}
}
- if (!err) {
- visit_check_list(v, &err);
- }
+ ok = visit_check_list(v, errp);
+ out_obj:
visit_end_list(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_UserDefOneList(*obj);
*obj = NULL;
}
- error_propagate(errp, err);
- return !err;
+ return ok;
}
bool visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp)
{
- Error *err = NULL;
-
if (!visit_type_UserDefOneList(v, "arg1", &obj->arg1, errp)) {
return false;
}
- error_propagate(errp, err);
- return !err;
+ return true;
}
[Uninteresting stuff omitted...]
static void qmp_marshal_output_UserDefOne(UserDefOne *ret_in, QObject **ret_out, Error **errp)
{
- Error *err = NULL;
Visitor *v;
v = qobject_output_visitor_new(ret_out);
- visit_type_UserDefOne(v, "unused", &ret_in, &err);
- if (!err) {
+ if (visit_type_UserDefOne(v, "unused", &ret_in, errp)) {
visit_complete(v, ret_out);
}
- error_propagate(errp, err);
visit_free(v);
v = qapi_dealloc_visitor_new();
visit_type_UserDefOne(v, "unused", &ret_in, NULL);
void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp)
{
Error *err = NULL;
+ bool ok = false;
Visitor *v;
UserDefOne *retval;
q_obj_my_command_arg arg = {0};
v = qobject_input_visitor_new(QOBJECT(args));
- visit_start_struct(v, NULL, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
goto out;
}
- visit_type_q_obj_my_command_arg_members(v, &arg, &err);
- if (!err) {
- visit_check_struct(v, &err);
+ if (visit_type_q_obj_my_command_arg_members(v, &arg, errp)) {
+ ok = visit_check_struct(v, errp);
}
visit_end_struct(v, NULL);
- if (err) {
+ if (!ok) {
goto out;
}
retval = qmp_my_command(arg.arg1, &err);
+ error_propagate(errp, err);
if (err) {
goto out;
}
- qmp_marshal_output_UserDefOne(retval, ret, &err);
+ qmp_marshal_output_UserDefOne(retval, ret, errp);
out:
- error_propagate(errp, err);
visit_free(v);
v = qapi_dealloc_visitor_new();
visit_start_struct(v, NULL, NULL, 0, NULL);
visit_end_struct(v, NULL);
visit_free(v);
}
+
[Uninteresting stuff omitted...]
$ cat qapi-generated/example-qapi-init-commands.h
[Uninteresting stuff omitted...]
ret = mcgen('''
%(lhs)sqmp_%(c_name)s(%(args)s&err);
+ error_propagate(errp, err);
''',
c_name=c_name(name), args=argstr, lhs=lhs)
if ret_type:
goto out;
}
- qmp_marshal_output_%(c_name)s(retval, ret, &err);
+ qmp_marshal_output_%(c_name)s(retval, ret, errp);
''',
c_name=ret_type.c_name())
return ret
static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, Error **errp)
{
- Error *err = NULL;
Visitor *v;
v = qobject_output_visitor_new(ret_out);
- visit_type_%(c_name)s(v, "unused", &ret_in, &err);
- if (!err) {
+ if (visit_type_%(c_name)s(v, "unused", &ret_in, errp)) {
visit_complete(v, ret_out);
}
- error_propagate(errp, err);
visit_free(v);
v = qapi_dealloc_visitor_new();
visit_type_%(c_name)s(v, "unused", &ret_in, NULL);
%(proto)s
{
Error *err = NULL;
+ bool ok = false;
Visitor *v;
''',
proto=build_marshal_proto(name))
ret += mcgen('''
v = qobject_input_visitor_new(QOBJECT(args));
- visit_start_struct(v, NULL, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
goto out;
}
''')
if have_args:
ret += mcgen('''
- visit_type_%(c_arg_type)s_members(v, &arg, &err);
- if (!err) {
- visit_check_struct(v, &err);
+ if (visit_type_%(c_arg_type)s_members(v, &arg, errp)) {
+ ok = visit_check_struct(v, errp);
}
''',
c_arg_type=arg_type.c_name())
else:
ret += mcgen('''
- visit_check_struct(v, &err);
+ ok = visit_check_struct(v, errp);
''')
ret += mcgen('''
visit_end_struct(v, NULL);
- if (err) {
+ if (!ok) {
goto out;
}
''')
ret += mcgen('''
out:
- error_propagate(errp, err);
visit_free(v);
''')
bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
{
- Error *err = NULL;
-
''',
c_name=c_name(name))
else:
ret += mcgen('''
case %(case)s:
- visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, &err);
- break;
+ return visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, errp);
''',
case=case_str,
c_type=var.type.c_name(), c_name=c_name(var.name))
''')
ret += mcgen('''
- error_propagate(errp, err);
- return !err;
+ return true;
}
''')
return ret
bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
%(c_name)s *tail;
size_t size = sizeof(**obj);
for (tail = *obj; tail;
tail = (%(c_name)s *)visit_next_list(v, (GenericList *)tail, size)) {
- visit_type_%(c_elt_type)s(v, NULL, &tail->value, &err);
- if (err) {
- break;
+ if (!visit_type_%(c_elt_type)s(v, NULL, &tail->value, errp)) {
+ goto out_obj;
}
}
- if (!err) {
- visit_check_list(v, &err);
- }
+ ok = visit_check_list(v, errp);
+out_obj:
visit_end_list(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;
}
- error_propagate(errp, err);
- return !err;
+ return ok;
}
''',
c_name=c_name(name), c_elt_type=element_type.c_name())
bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
if (!visit_start_alternate(v, name, (GenericAlternate **)obj,
sizeof(**obj), errp)) {
if (!*obj) {
/* incomplete */
assert(visit_is_dealloc(v));
+ ok = true;
goto out_obj;
}
switch ((*obj)->type) {
case=var.type.alternate_qtype())
if isinstance(var.type, QAPISchemaObjectType):
ret += mcgen('''
- visit_start_struct(v, name, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, name, NULL, 0, errp)) {
break;
}
- visit_type_%(c_type)s_members(v, &(*obj)->u.%(c_name)s, &err);
- if (!err) {
- visit_check_struct(v, &err);
+ if (visit_type_%(c_type)s_members(v, &(*obj)->u.%(c_name)s, errp)) {
+ ok = visit_check_struct(v, errp);
}
visit_end_struct(v, NULL);
''',
c_name=c_name(var.name))
else:
ret += mcgen('''
- visit_type_%(c_type)s(v, name, &(*obj)->u.%(c_name)s, &err);
+ ok = visit_type_%(c_type)s(v, name, &(*obj)->u.%(c_name)s, errp);
''',
c_type=var.type.c_name(),
c_name=c_name(var.name))
abort();
default:
assert(visit_is_input(v));
- error_setg(&err, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"%(name)s");
/* Avoid passing invalid *obj to qapi_free_%(c_name)s() */
g_free(*obj);
}
out_obj:
visit_end_alternate(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;
}
- error_propagate(errp, err);
- return !err;
+ return ok;
}
''',
name=name, c_name=c_name(name))
bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
if (!visit_start_struct(v, name, (void **)obj, sizeof(%(c_name)s), errp)) {
return false;
assert(visit_is_dealloc(v));
goto out_obj;
}
- visit_type_%(c_name)s_members(v, *obj, &err);
- if (err) {
+ if (!visit_type_%(c_name)s_members(v, *obj, errp)) {
goto out_obj;
}
- visit_check_struct(v, &err);
+ ok = visit_check_struct(v, errp);
out_obj:
visit_end_struct(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;
}
- error_propagate(errp, err);
- return !err;
+ return ok;
}
''',
c_name=c_name(name))