diff options
author | Eric Blake <eblake@redhat.com> | 2021-01-13 16:10:12 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-01-28 08:08:45 +0100 |
commit | c3033fd372fdaf5b89190136a74b3d78880b85d6 (patch) | |
tree | 6c2464ae3f51b43702c448606acb3a6c21b6b634 /block/qapi.c | |
parent | dc13f40c6ba291e31d09053815c230ed88c8921f (diff) | |
download | qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.zip qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.tar.gz qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.tar.bz2 |
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 'block/qapi.c')
-rw-r--r-- | block/qapi.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/block/qapi.c b/block/qapi.c index 0ca206f..3a1186f 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -418,17 +418,12 @@ static uint64List *uint64_list(uint64_t *list, int size) { int i; uint64List *out_list = NULL; - uint64List **pout_list = &out_list; + uint64List **tail = &out_list; for (i = 0; i < size; i++) { - uint64List *entry = g_new(uint64List, 1); - entry->value = list[i]; - *pout_list = entry; - pout_list = &entry->next; + QAPI_LIST_APPEND(tail, list[i]); } - *pout_list = NULL; - return out_list; } @@ -636,26 +631,21 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes, bool query_nodes, Error **errp) { - BlockStatsList *head = NULL, **p_next = &head; + BlockStatsList *head = NULL, **tail = &head; BlockBackend *blk; BlockDriverState *bs; /* Just to be safe if query_nodes is not always initialized */ if (has_query_nodes && query_nodes) { for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) { - BlockStatsList *info = g_malloc0(sizeof(*info)); AioContext *ctx = bdrv_get_aio_context(bs); aio_context_acquire(ctx); - info->value = bdrv_query_bds_stats(bs, false); + QAPI_LIST_APPEND(tail, bdrv_query_bds_stats(bs, false)); aio_context_release(ctx); - - *p_next = info; - p_next = &info->next; } } else { for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { - BlockStatsList *info; AioContext *ctx = blk_get_aio_context(blk); BlockStats *s; char *qdev; @@ -680,10 +670,7 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes, bdrv_query_blk_stats(s->stats, blk); aio_context_release(ctx); - info = g_malloc0(sizeof(*info)); - info->value = s; - *p_next = info; - p_next = &info->next; + QAPI_LIST_APPEND(tail, s); } } |