diff options
author | Eric Blake | 2021-01-13 23:10:12 +0100 |
---|---|---|
committer | Markus Armbruster | 2021-01-28 08:08:45 +0100 |
commit | c3033fd372fdaf5b89190136a74b3d78880b85d6 (patch) | |
tree | 6c2464ae3f51b43702c448606acb3a6c21b6b634 /backends | |
parent | qapi: Introduce QAPI_LIST_APPEND (diff) | |
download | qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.tar.gz qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.tar.xz qemu-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 'backends')
-rw-r--r-- | backends/hostmem.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/backends/hostmem.c b/backends/hostmem.c index 9f9ac95edd..be0c3b079f 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -80,7 +80,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name, { HostMemoryBackend *backend = MEMORY_BACKEND(obj); uint16List *host_nodes = NULL; - uint16List **node = &host_nodes; + uint16List **tail = &host_nodes; unsigned long value; value = find_first_bit(backend->host_nodes, MAX_NODES); @@ -88,9 +88,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name, goto ret; } - *node = g_malloc0(sizeof(**node)); - (*node)->value = value; - node = &(*node)->next; + QAPI_LIST_APPEND(tail, value); do { value = find_next_bit(backend->host_nodes, MAX_NODES, value + 1); @@ -98,9 +96,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name, break; } - *node = g_malloc0(sizeof(**node)); - (*node)->value = value; - node = &(*node)->next; + QAPI_LIST_APPEND(tail, value); } while (true); ret: |