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 /hw/mem | |
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 'hw/mem')
-rw-r--r-- | hw/mem/memory-device.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index cf0627fd01..d9f8301711 100644 --- a/hw/mem/memory-device.c +++ b/hw/mem/memory-device.c @@ -199,7 +199,7 @@ out: MemoryDeviceInfoList *qmp_memory_device_list(void) { GSList *devices = NULL, *item; - MemoryDeviceInfoList *list = NULL, *prev = NULL; + MemoryDeviceInfoList *list = NULL, **tail = &list; object_child_foreach(qdev_get_machine(), memory_device_build_list, &devices); @@ -207,19 +207,11 @@ MemoryDeviceInfoList *qmp_memory_device_list(void) for (item = devices; item; item = g_slist_next(item)) { const MemoryDeviceState *md = MEMORY_DEVICE(item->data); const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(item->data); - MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1); MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1); mdc->fill_device_info(md, info); - elem->value = info; - elem->next = NULL; - if (prev) { - prev->next = elem; - } else { - list = elem; - } - prev = elem; + QAPI_LIST_APPEND(tail, info); } g_slist_free(devices); |