From: Markus Armbruster <arm...@redhat.com>

Changing implicit indentation in the middle of generating a block
makes following the code being generated unnecessarily hard.

Signed-off-by: Markus Armbruster <arm...@redhat.com>
Reviewed-by: Eric Blake <ebl...@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitul...@redhat.com>
---
 scripts/qapi-visit.py | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 9f22eee..28176ba 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -128,12 +128,14 @@ if (!err) {
 ''',
         name=full_name)
 
+    ret += mcgen('''
+    /* Always call end_struct if start_struct succeeded.  */
+    visit_end_struct(m, &err);
+}
+error_propagate(errp, err);
+''')
     pop_indent()
     ret += mcgen('''
-        /* Always call end_struct if start_struct succeeded.  */
-        visit_end_struct(m, &err);
-    }
-    error_propagate(errp, err);
 }
 ''')
     return ret
@@ -289,19 +291,15 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, 
const char *name, Error **
 ''',
                  name=name)
 
-
-    push_indent()
     push_indent()
     push_indent()
 
     if base:
         ret += mcgen('''
-    visit_type_%(name)s_fields(m, obj, &err);
+        visit_type_%(name)s_fields(m, obj, &err);
 ''',
             name=name)
 
-    pop_indent()
-
     if not discriminator:
         disc_key = "type"
     else:
@@ -343,19 +341,17 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, 
const char *name, Error **
         }
         error_propagate(errp, err);
         err = NULL;
-    }
 ''')
     pop_indent()
-    ret += mcgen('''
-        /* Always call end_struct if start_struct succeeded.  */
-        visit_end_struct(m, &err);
-    }
-    error_propagate(errp, err);
-}
-''')
+    pop_indent()
 
-    pop_indent();
     ret += mcgen('''
+            }
+            /* Always call end_struct if start_struct succeeded.  */
+            visit_end_struct(m, &err);
+        }
+        error_propagate(errp, err);
+    }
 }
 ''')
 
-- 
1.9.0


Reply via email to