From patchwork Fri Mar 4 16:45:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8506191 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C1CC49F7CA for ; Fri, 4 Mar 2016 16:46:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22D2120125 for ; Fri, 4 Mar 2016 16:46:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 39E3220120 for ; Fri, 4 Mar 2016 16:46:00 +0000 (UTC) Received: from localhost ([::1]:42253 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1absrX-0001C7-K0 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 04 Mar 2016 11:45:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1absr9-00018Y-QA for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:45:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1absr8-0005Zt-76 for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:45:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1absr8-0005Zi-0G for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:45:34 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 9C68232E883 for ; Fri, 4 Mar 2016 16:45:33 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-56.ams2.redhat.com [10.36.116.56]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u24GjVsT027215 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 4 Mar 2016 11:45:33 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 980543004F89; Fri, 4 Mar 2016 17:45:29 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 4 Mar 2016 17:45:26 +0100 Message-Id: <1457109928-4881-11-git-send-email-armbru@redhat.com> In-Reply-To: <1457109928-4881-1-git-send-email-armbru@redhat.com> References: <1457109928-4881-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/12] qapi: Avoid use of 'data' member of QAPI unions 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Blake QAPI code generators currently create a 'void *data' member as part of the anonymous union embedded in the C struct corresponding to a QAPI union. However, directly assigning to this member of the union feels a bit fishy, when we can assign to another member of the struct instead. Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrange Message-Id: <1457021813-10704-9-git-send-email-eblake@redhat.com> --- blockdev.c | 31 +++++++++++++++++-------------- ui/input.c | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/blockdev.c b/blockdev.c index d4bc435..0f20c65 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1202,15 +1202,11 @@ void hmp_commit(Monitor *mon, const QDict *qdict) } } -static void blockdev_do_action(TransactionActionKind type, void *data, - Error **errp) +static void blockdev_do_action(TransactionAction *action, Error **errp) { - TransactionAction action; TransactionActionList list; - action.type = type; - action.u.data = data; - list.value = &action; + list.value = action; list.next = NULL; qmp_transaction(&list, false, NULL, errp); } @@ -1236,8 +1232,11 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, .has_mode = has_mode, .mode = mode, }; - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC, - &snapshot, errp); + TransactionAction action = { + .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC, + .u.blockdev_snapshot_sync = &snapshot, + }; + blockdev_do_action(&action, errp); } void qmp_blockdev_snapshot(const char *node, const char *overlay, @@ -1247,9 +1246,11 @@ void qmp_blockdev_snapshot(const char *node, const char *overlay, .node = (char *) node, .overlay = (char *) overlay }; - - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT, - &snapshot_data, errp); + TransactionAction action = { + .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT, + .u.blockdev_snapshot = &snapshot_data, + }; + blockdev_do_action(&action, errp); } void qmp_blockdev_snapshot_internal_sync(const char *device, @@ -1260,9 +1261,11 @@ void qmp_blockdev_snapshot_internal_sync(const char *device, .device = (char *) device, .name = (char *) name }; - - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC, - &snapshot, errp); + TransactionAction action = { + .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC, + .u.blockdev_snapshot_internal_sync = &snapshot, + }; + blockdev_do_action(&action, errp); } SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device, diff --git a/ui/input.c b/ui/input.c index 13ee117..b035f86 100644 --- a/ui/input.c +++ b/ui/input.c @@ -470,7 +470,7 @@ InputEvent *qemu_input_event_new_move(InputEventKind kind, InputMoveEvent *move = g_new0(InputMoveEvent, 1); evt->type = kind; - evt->u.data = move; + evt->u.rel = move; /* evt->u.rel is the same as evt->u.abs */ move->axis = axis; move->value = value; return evt;