qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 12/15] qapi-visit: Use common idiom in gen_visit_fields_decl()
Date: Fri, 19 Feb 2016 13:18:03 +0100	[thread overview]
Message-ID: <1455884286-26272-13-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1455884286-26272-1-git-send-email-armbru@redhat.com>

From: Eric Blake <eblake@redhat.com>

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>
---
 scripts/qapi-visit.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index dfeef71..d7d7ed5 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):
-- 
2.4.3

  parent reply	other threads:[~2016-02-19 12:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19 12:17 [Qemu-devel] [PULL 00/15] QAPI patches for 2016-02-19 Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 01/15] qapi-visit: Honor prefix of discriminator enum Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 02/15] qapi: Simplify excess input reporting in input visitors Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 03/15] qapi: Forbid empty unions and useless alternates Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 04/15] qapi: Forbid 'any' inside an alternate Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 05/15] qapi: Add tests of complex objects within alternate Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 06/15] qapi-visit: Simplify how we visit common union members Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 07/15] qapi: Visit variants in visit_type_FOO_fields() Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 08/15] qapi-visit: Unify struct and union visit Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 09/15] qapi-visit: Less indirection in visit_type_Foo_fields() Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 10/15] qapi: Adjust layout of FooList types Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 11/15] qapi: Emit structs used as variants in topological order Markus Armbruster
2016-02-19 12:18 ` Markus Armbruster [this message]
2016-02-19 12:18 ` [Qemu-devel] [PULL 13/15] qapi: Don't box struct branch of alternate Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 14/15] qapi: Don't box branches of flat unions Markus Armbruster
2016-02-23 14:50   ` Daniel P. Berrange
2016-02-23 15:18     ` Eric Blake
2016-02-23 15:30       ` Eric Blake
2016-02-23 15:33       ` Daniel P. Berrange
2016-02-19 12:18 ` [Qemu-devel] [PULL 15/15] qapi: Change visit_start_implicit_struct to visit_start_alternate Markus Armbruster
2016-02-19 15:19 ` [Qemu-devel] [PULL 00/15] QAPI patches for 2016-02-19 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455884286-26272-13-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).