mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
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>
This commit is contained in:
parent
c3033fd372
commit
95b3a8c8a8
13 changed files with 141 additions and 303 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue