From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Juan Quintela <quintela@redhat.com>
Subject: [PATCH v3 3/7] migration: Refactor migrate_cap_add
Date: Wed, 23 Dec 2020 16:10:58 -0600 [thread overview]
Message-ID: <20201223221102.390740-4-eblake@redhat.com> (raw)
In-Reply-To: <20201223221102.390740-1-eblake@redhat.com>
Instead of taking a list parameter and returning a new head at a
distance, just return the new item for the caller to insert into a
list via QAPI_LIST_PREPEND. Update some variable names to avoid long
lines, and drop a useless comment.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
migration/migration.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index e0dbde4091c9..bba6e5148138 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1654,29 +1654,27 @@ void migrate_set_state(int *state, int old_state, int new_state)
}
}
-static MigrationCapabilityStatusList *migrate_cap_add(
- MigrationCapabilityStatusList *list,
- MigrationCapability index,
- bool state)
+static MigrationCapabilityStatus *migrate_cap_add(MigrationCapability index,
+ bool state)
{
- MigrationCapabilityStatusList *cap;
+ MigrationCapabilityStatus *cap;
- cap = g_new0(MigrationCapabilityStatusList, 1);
- cap->value = g_new0(MigrationCapabilityStatus, 1);
- cap->value->capability = index;
- cap->value->state = state;
- cap->next = list;
+ cap = g_new0(MigrationCapabilityStatus, 1);
+ cap->capability = index;
+ cap->state = state;
return cap;
}
void migrate_set_block_enabled(bool value, Error **errp)
{
- MigrationCapabilityStatusList *cap;
+ MigrationCapabilityStatusList *caps = NULL;
+ MigrationCapabilityStatus *cap;
- cap = migrate_cap_add(NULL, MIGRATION_CAPABILITY_BLOCK, value);
- qmp_migrate_set_capabilities(cap, errp);
- qapi_free_MigrationCapabilityStatusList(cap);
+ cap = migrate_cap_add(MIGRATION_CAPABILITY_BLOCK, value);
+ QAPI_LIST_PREPEND(caps, cap);
+ qmp_migrate_set_capabilities(caps, errp);
+ qapi_free_MigrationCapabilityStatusList(caps);
}
static void migrate_set_block_incremental(MigrationState *s, bool value)
@@ -3863,13 +3861,12 @@ static bool migration_object_check(MigrationState *ms, Error **errp)
for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
if (ms->enabled_capabilities[i]) {
- head = migrate_cap_add(head, i, true);
+ QAPI_LIST_PREPEND(head, migrate_cap_add(i, true));
}
}
ret = migrate_caps_check(cap_list, head, errp);
- /* It works with head == NULL */
qapi_free_MigrationCapabilityStatusList(head);
return ret;
--
2.29.2
next prev parent reply other threads:[~2020-12-23 22:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-23 22:10 [PATCH v3 0/7] Common macros for QAPI list growth Eric Blake
2020-12-23 22:10 ` [PATCH v3 1/7] net: Clarify early exit condition Eric Blake
2021-01-13 12:57 ` Markus Armbruster
2020-12-23 22:10 ` [PATCH v3 2/7] rocker: Revamp fp_port_get_info Eric Blake
2021-01-13 12:57 ` Markus Armbruster
2020-12-23 22:10 ` Eric Blake [this message]
2021-01-13 12:58 ` [PATCH v3 3/7] migration: Refactor migrate_cap_add Markus Armbruster
2020-12-23 22:10 ` [PATCH v3 4/7] qapi: Use QAPI_LIST_PREPEND() where possible Eric Blake
2020-12-23 22:10 ` Eric Blake
2021-01-13 13:00 ` Markus Armbruster
2020-12-23 22:11 ` [PATCH v3 5/7] qapi: Introduce QAPI_LIST_APPEND Eric Blake
2020-12-24 6:14 ` Vladimir Sementsov-Ogievskiy
2021-01-13 13:04 ` Markus Armbruster
2021-01-13 14:08 ` Eric Blake
2020-12-23 22:11 ` [PATCH v3 6/7] qapi: Use QAPI_LIST_APPEND in trivial cases Eric Blake
2020-12-23 22:11 ` Eric Blake
2020-12-24 9:56 ` Vladimir Sementsov-Ogievskiy
2020-12-24 9:56 ` Vladimir Sementsov-Ogievskiy
2021-01-13 14:10 ` Eric Blake
2021-01-13 14:10 ` Eric Blake
2021-01-13 13:16 ` Markus Armbruster
2021-01-13 13:16 ` Markus Armbruster
2021-01-13 14:11 ` Eric Blake
2021-01-13 14:11 ` Eric Blake
2020-12-23 22:11 ` [PATCH v3 7/7] qapi: More complex uses of QAPI_LIST_APPEND Eric Blake
2020-12-24 11:35 ` Vladimir Sementsov-Ogievskiy
2021-01-13 13:31 ` Markus Armbruster
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=20201223221102.390740-4-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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.