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>
This commit is contained in:
Eric Blake 2021-01-13 16:10:12 -06:00 committed by Markus Armbruster
parent dc13f40c6b
commit c3033fd372
20 changed files with 96 additions and 222 deletions

View file

@ -164,28 +164,25 @@ static JobInfo *job_query_single(Job *job, Error **errp)
JobInfoList *qmp_query_jobs(Error **errp)
{
JobInfoList *head = NULL, **p_next = &head;
JobInfoList *head = NULL, **tail = &head;
Job *job;
for (job = job_next(NULL); job; job = job_next(job)) {
JobInfoList *elem;
JobInfo *value;
AioContext *aio_context;
if (job_is_internal(job)) {
continue;
}
elem = g_new0(JobInfoList, 1);
aio_context = job->aio_context;
aio_context_acquire(aio_context);
elem->value = job_query_single(job, errp);
value = job_query_single(job, errp);
aio_context_release(aio_context);
if (!elem->value) {
g_free(elem);
if (!value) {
qapi_free_JobInfoList(head);
return NULL;
}
*p_next = elem;
p_next = &elem->next;
QAPI_LIST_APPEND(tail, value);
}
return head;