aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-02-17 23:48:25 -0700
committerMarkus Armbruster <armbru@redhat.com>2016-02-19 11:08:57 +0100
commit2208d64998c5f867ccee7eeee298971685bf822d (patch)
treed265df29412f0eba418ebc28abc169891da75504
parent1de5d4ca0752138034305f3d4e8fe17ef6503569 (diff)
qapi-visit: Use common idiom in gen_visit_fields_decl()
We have several instances of methods that do an early exit if output is not needed, then log that output is being generated, and finally produce the output; see qapi-types.py:gen_object() and qapi-visit.py:gen_visit_implicit_struct(). The odd man out was gen_visit_fields_decl(); rearrange it to be more like the others. No semantic change or difference to generated code. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1455778109-6278-12-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r--scripts/qapi-visit.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index dfeef7196b..d7d7ed5a32 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -35,15 +35,14 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error **
def gen_visit_fields_decl(typ):
- ret = ''
- if typ.name not in struct_fields_seen:
- ret += mcgen('''
+ if typ.name in struct_fields_seen:
+ return ''
+ struct_fields_seen.add(typ.name)
+ return mcgen('''
static void visit_type_%(c_type)s_fields(Visitor *v, %(c_type)s *obj, Error **errp);
''',
- c_type=typ.c_name())
- struct_fields_seen.add(typ.name)
- return ret
+ c_type=typ.c_name())
def gen_visit_implicit_struct(typ):