summaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2021-01-13 16:10:12 -0600
committerMarkus Armbruster <armbru@redhat.com>2021-01-28 08:08:45 +0100
commitc3033fd372fdaf5b89190136a74b3d78880b85d6 (patch)
tree6c2464ae3f51b43702c448606acb3a6c21b6b634 /blockdev.c
parentdc13f40c6ba291e31d09053815c230ed88c8921f (diff)
downloadqemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.zip
qapi: Use QAPI_LIST_APPEND in trivial cases
The easiest spots to use QAPI_LIST_APPEND are where we already have an obvious pointer to the tail of a list. While at it, consistently use the variable name 'tail' for that purpose. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210113221013.390592-5-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/blockdev.c b/blockdev.c
index 93417f6302..b250b9b959 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3725,28 +3725,25 @@ void qmp_x_blockdev_change(const char *parent, bool has_child,
BlockJobInfoList *qmp_query_block_jobs(Error **errp)
{
- BlockJobInfoList *head = NULL, **p_next = &head;
+ BlockJobInfoList *head = NULL, **tail = &head;
BlockJob *job;
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
- BlockJobInfoList *elem;
+ BlockJobInfo *value;
AioContext *aio_context;
if (block_job_is_internal(job)) {
continue;
}
- elem = g_new0(BlockJobInfoList, 1);
aio_context = blk_get_aio_context(job->blk);
aio_context_acquire(aio_context);
- elem->value = block_job_query(job, errp);
+ value = block_job_query(job, errp);
aio_context_release(aio_context);
- if (!elem->value) {
- g_free(elem);
+ if (!value) {
qapi_free_BlockJobInfoList(head);
return NULL;
}
- *p_next = elem;
- p_next = &elem->next;
+ QAPI_LIST_APPEND(tail, value);
}
return head;