From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 10/12] qapi: Avoid use of 'data' member of QAPI unions
Date: Fri, 4 Mar 2016 17:45:26 +0100 [thread overview]
Message-ID: <1457109928-4881-11-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>
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 <eblake@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
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;
--
2.4.3
next prev 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 ` Markus Armbruster [this message]
2016-03-04 16:45 ` [Qemu-devel] [PULL 11/12] chardev: Drop useless ChardevDummy type Markus Armbruster
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-11-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).