From patchwork Thu Feb 25 23:38:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 588465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 67B11140325 for ; Fri, 26 Feb 2016 10:41:34 +1100 (AEDT) Received: from localhost ([::1]:46443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5XI-0007b2-F6 for incoming@patchwork.ozlabs.org; Thu, 25 Feb 2016 18:41:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5Uz-0002lr-8Y for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZ5Uy-0005RY-FF for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5Uy-0005RM-7m for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:08 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D6E027EBAE; Thu, 25 Feb 2016 23:39:07 +0000 (UTC) Received: from red.redhat.com (ovpn-113-105.phx2.redhat.com [10.3.113.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1PNd2Ng002433; Thu, 25 Feb 2016 18:39:07 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 25 Feb 2016 16:38:37 -0700 Message-Id: <1456443528-13901-9-git-send-email-eblake@redhat.com> In-Reply-To: <1456443528-13901-1-git-send-email-eblake@redhat.com> References: <1456443528-13901-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Samuel Thibault , armbru@redhat.com, Paolo Bonzini Subject: [Qemu-devel] [PATCH v2 08/19] chardev: Drop useless ChardevDummy type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Daniel P. Berrange --- v2: add R-b --- backends/baum.c | 2 +- backends/msmouse.c | 2 +- qemu-char.c | 6 +++--- qapi-schema.json | 15 ++++++--------- 4 files changed, 11 insertions(+), 14 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/qemu-char.c b/qemu-char.c index cfc82bc..6a0fc74 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) { @@ -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); diff --git a/qapi-schema.json b/qapi-schema.json index 7b8f2a1..66cc364 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',