diff options
author | Eric Blake <eblake@redhat.com> | 2021-01-13 16:10:13 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-01-28 08:08:45 +0100 |
commit | 95b3a8c8a82a34ca874ac0d4a9bbbdb38034acf3 (patch) | |
tree | 76d842228434aa8ac1dc10f8fcc4bfc5cce422d5 /migration/migration.c | |
parent | c3033fd372fdaf5b89190136a74b3d78880b85d6 (diff) |
qapi: More complex uses of QAPI_LIST_APPEND
These cases require a bit more thought to review; in each case, the
code was appending to a list, but not with a FOOList **tail variable.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210113221013.390592-6-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Flawed change to qmp_guest_network_get_interfaces() dropped]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'migration/migration.c')
-rw-r--r-- | migration/migration.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/migration/migration.c b/migration/migration.c index d5136419bf..1986cb8573 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -793,29 +793,21 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value) MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) { - MigrationCapabilityStatusList *head = NULL; - MigrationCapabilityStatusList *caps; + MigrationCapabilityStatusList *head = NULL, **tail = &head; + MigrationCapabilityStatus *caps; MigrationState *s = migrate_get_current(); int i; - caps = NULL; /* silence compiler warning */ for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) { #ifndef CONFIG_LIVE_BLOCK_MIGRATION if (i == MIGRATION_CAPABILITY_BLOCK) { continue; } #endif - if (head == NULL) { - head = g_malloc0(sizeof(*caps)); - caps = head; - } else { - caps->next = g_malloc0(sizeof(*caps)); - caps = caps->next; - } - caps->value = - g_malloc(sizeof(*caps->value)); - caps->value->capability = i; - caps->value->state = s->enabled_capabilities[i]; + caps = g_malloc0(sizeof(*caps)); + caps->capability = i; + caps->state = s->enabled_capabilities[i]; + QAPI_LIST_APPEND(tail, caps); } return head; |