From patchwork Thu Mar 3 16:16:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8493731 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B0D2C0553 for ; Thu, 3 Mar 2016 16:17:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2CA020351 for ; Thu, 3 Mar 2016 16:17:24 +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 3538B20295 for ; Thu, 3 Mar 2016 16:17:24 +0000 (UTC) Received: from localhost ([::1]:35994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abVwJ-0003E7-Gz for patchwork-qemu-devel@patchwork.kernel.org; Thu, 03 Mar 2016 11:17:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abVvz-00034f-Qa for qemu-devel@nongnu.org; Thu, 03 Mar 2016 11:17:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abVvy-0003wd-Oj for qemu-devel@nongnu.org; Thu, 03 Mar 2016 11:17:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37880) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abVvv-0003sm-Hn; Thu, 03 Mar 2016 11:16:59 -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 4541CC00F1E7; Thu, 3 Mar 2016 16:16:59 +0000 (UTC) Received: from red.redhat.com (ovpn-113-165.phx2.redhat.com [10.3.113.165]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u23GGsrs021507; Thu, 3 Mar 2016 11:16:58 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 3 Mar 2016 09:16:50 -0700 Message-Id: <1457021813-10704-9-git-send-email-eblake@redhat.com> In-Reply-To: <1457021813-10704-1-git-send-email-eblake@redhat.com> References: <1457021813-10704-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: Kevin Wolf , armbru@redhat.com, "open list:Block layer core" , Gerd Hoffmann Subject: [Qemu-devel] [PATCH v3 08/10] 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 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 --- v3: retitle, tweak commit message and code comment v2: add R-b v1: no change Previously posted as part of qapi cleanup series F: v6: rebase to latest --- 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;