All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 11/12] chardev: Drop useless ChardevDummy type
Date: Fri,  4 Mar 2016 17:45:27 +0100	[thread overview]
Message-ID: <1457109928-4881-12-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1457109928-4881-1-git-send-email-armbru@redhat.com>

From: Eric Blake <eblake@redhat.com>

Commit d0d7708b made ChardevDummy be an empty wrapper type around
ChardevCommon.  But there is no technical reason for this indirection,
so simplify the code by directly using the base type.

Also change the fallback assignment to assign u.null rather than
u.data, since a future patch will remove the data member of the C
struct generated for QAPI unions.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>

Message-Id: <1457106160-23614-1-git-send-email-eblake@redhat.com>
---
 backends/baum.c    |  2 +-
 backends/msmouse.c |  2 +-
 qapi-schema.json   | 15 ++++++---------
 qemu-char.c        |  8 ++++----
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/backends/baum.c b/backends/baum.c
index 374562a..c11320e 100644
--- a/backends/baum.c
+++ b/backends/baum.c
@@ -567,7 +567,7 @@ static CharDriverState *chr_baum_init(const char *id,
                                       ChardevReturn *ret,
                                       Error **errp)
 {
-    ChardevCommon *common = qapi_ChardevDummy_base(backend->u.braille);
+    ChardevCommon *common = backend->u.braille;
     BaumDriverState *baum;
     CharDriverState *chr;
     brlapi_handle_t *handle;
diff --git a/backends/msmouse.c b/backends/msmouse.c
index 9a82efd..5e1833c 100644
--- a/backends/msmouse.c
+++ b/backends/msmouse.c
@@ -68,7 +68,7 @@ static CharDriverState *qemu_chr_open_msmouse(const char *id,
                                               ChardevReturn *ret,
                                               Error **errp)
 {
-    ChardevCommon *common = qapi_ChardevDummy_base(backend->u.msmouse);
+    ChardevCommon *common = backend->u.msmouse;
     CharDriverState *chr;
 
     chr = qemu_chr_alloc(common, errp);
diff --git a/qapi-schema.json b/qapi-schema.json
index 42fd61b..362c9d8 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3323,23 +3323,20 @@
 #
 # Since: 1.4 (testdev since 2.2)
 ##
-{ 'struct': 'ChardevDummy', 'data': { },
-  'base': 'ChardevCommon' }
-
 { 'union': 'ChardevBackend', 'data': { 'file'   : 'ChardevFile',
                                        'serial' : 'ChardevHostdev',
                                        'parallel': 'ChardevHostdev',
                                        'pipe'   : 'ChardevHostdev',
                                        'socket' : 'ChardevSocket',
                                        'udp'    : 'ChardevUdp',
-                                       'pty'    : 'ChardevDummy',
-                                       'null'   : 'ChardevDummy',
+                                       'pty'    : 'ChardevCommon',
+                                       'null'   : 'ChardevCommon',
                                        'mux'    : 'ChardevMux',
-                                       'msmouse': 'ChardevDummy',
-                                       'braille': 'ChardevDummy',
-                                       'testdev': 'ChardevDummy',
+                                       'msmouse': 'ChardevCommon',
+                                       'braille': 'ChardevCommon',
+                                       'testdev': 'ChardevCommon',
                                        'stdio'  : 'ChardevStdio',
-                                       'console': 'ChardevDummy',
+                                       'console': 'ChardevCommon',
                                        'spicevmc' : 'ChardevSpiceChannel',
                                        'spiceport' : 'ChardevSpicePort',
                                        'vc'     : 'ChardevVC',
diff --git a/qemu-char.c b/qemu-char.c
index af31102..e0147f3 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -420,7 +420,7 @@ static CharDriverState *qemu_chr_open_null(const char *id,
                                            Error **errp)
 {
     CharDriverState *chr;
-    ChardevCommon *common = qapi_ChardevDummy_base(backend->u.null);
+    ChardevCommon *common = backend->u.null;
 
     chr = qemu_chr_alloc(common, errp);
     if (!chr) {
@@ -1366,7 +1366,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
     PtyCharDriver *s;
     int master_fd, slave_fd;
     char pty_name[PATH_MAX];
-    ChardevCommon *common = qapi_ChardevDummy_base(backend->u.pty);
+    ChardevCommon *common = backend->u.pty;
 
     master_fd = qemu_openpty_raw(&slave_fd, pty_name);
     if (master_fd < 0) {
@@ -2183,7 +2183,7 @@ static CharDriverState *qemu_chr_open_win_con(const char *id,
                                               ChardevReturn *ret,
                                               Error **errp)
 {
-    ChardevCommon *common = qapi_ChardevDummy_base(backend->u.console);
+    ChardevCommon *common = backend->u.console;
     return qemu_chr_open_win_file(GetStdHandle(STD_OUTPUT_HANDLE),
                                   common, errp);
 }
@@ -3817,7 +3817,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
     } else {
         ChardevCommon *cc = g_new0(ChardevCommon, 1);
         qemu_chr_parse_common(opts, cc);
-        backend->u.data = cc;
+        backend->u.null = cc; /* Any ChardevCommon member would work */
     }
 
     ret = qmp_chardev_add(bid ? bid : id, backend, errp);
-- 
2.4.3

  parent reply	other threads:[~2016-03-04 16:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04 16:45 [Qemu-devel] [PULL 00/12] QAPI patches for 2016-03-04 Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 01/12] qmp-shell: fix pretty printing of JSON responses Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 02/12] qapi-dealloc: Reduce use outside of generated code Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 03/12] qapi: Rename 'fields' to 'members' in generator Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 04/12] qapi: Rename 'fields' to 'members' in generated C code Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 05/12] qapi-visit: Expose visit_type_FOO_members() Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 06/12] qapi: Update docs to match recent generator changes Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 07/12] chardev: Shorten references into ChardevBackend Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 08/12] util: Shorten references into SocketAddress Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 09/12] ui: Shorten references into InputEvent Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 10/12] qapi: Avoid use of 'data' member of QAPI unions Markus Armbruster
2016-03-04 16:45 ` Markus Armbruster [this message]
2016-03-04 16:45 ` [Qemu-devel] [PULL 12/12] qapi: Drop useless 'data' member of unions Markus Armbruster
2016-03-04 17:43 ` [Qemu-devel] [PULL 00/12] QAPI patches for 2016-03-04 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=1457109928-4881-12-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.