summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-05-07 09:53:48 +0200
committerLuiz Capitulino <lcapitulino@redhat.com>2014-05-15 14:00:45 -0400
commit4fa953f20d418256504d24ea16f1b39791d12e5b (patch)
treefa0b470c4678738bf9b94f2054b5174acf31775a /scripts
parent468866b816f13c8141b692ac0280706c16b30185 (diff)
downloadqemu-4fa953f20d418256504d24ea16f1b39791d12e5b.zip
qapi: Clean up shadowing of parameters and locals in inner scopes
By un-inlining the visit of nested complex types. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi-visit.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 28176ba734..57be9bf00c 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -35,6 +35,19 @@ def generate_visit_struct_fields(name, field_prefix, fn_prefix, members, base =
nested_field_prefix = "%s%s." % (field_prefix, argname)
ret += generate_visit_struct_fields(name, nested_field_prefix,
nested_fn_prefix, argentry)
+ ret += mcgen('''
+
+static void visit_type_%(full_name)s_field_%(c_name)s(Visitor *m, %(name)s **obj, Error **errp)
+{
+ Error *err = NULL;
+''',
+ name=name, full_name=full_name, c_name=c_var(argname))
+ push_indent()
+ ret += generate_visit_struct_body(full_name, argname, argentry)
+ pop_indent()
+ ret += mcgen('''
+}
+''')
ret += mcgen('''
@@ -69,7 +82,10 @@ if ((*obj)->%(prefix)shas_%(c_name)s) {
push_indent()
if structured:
- ret += generate_visit_struct_body(full_name, argname, argentry)
+ ret += mcgen('''
+visit_type_%(full_name)s_field_%(c_name)s(m, obj, &err);
+''',
+ full_name=full_name, c_name=c_var(argname))
else:
ret += mcgen('''
visit_type_%(type)s(m, &(*obj)->%(c_prefix)s%(c_name)s, "%(name)s", &err);
@@ -106,8 +122,6 @@ if (!error_is_set(errp)) {
if len(field_prefix):
ret += mcgen('''
-Error **errp = &err; /* from outer scope */
-Error *err = NULL;
visit_start_struct(m, NULL, "", "%(name)s", 0, &err);
''',
name=name)