From nobody Sun Oct 5 17:36:29 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608761680; cv=none; d=zohomail.com; s=zohoarc; b=j8c2UpTbAiBuyxDl96eooN2dC9+cl7ZsFtXDJoyzOigmjYp0fn/jZJBJYCQID7wgsUX+3kHYPfaeUveyZpaXGC5urofaLEqW1BhO00XRSfezzBiaNh3tJsyGtjuR4MEFbscMZiLcQST5G3HyH4si9UFotFZnGBUDX83ADSHICF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608761680; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9xmHO5fyVoINQziFIJJPHdUlbh8oTjbOt4cQUUkqO0w=; b=g+EQi3w2ijd+sv8QmjSVob83RGYUFuxwIYJJNpnK3t+7ZSD/+1IjcTvo0IghudUdWETXbCyRtmqOSIBSKmVT/ccG0jT1OJH5hDqADjQNNsUkX0IQHQJW+eYbzCQ7DPORkC5VgKlmtBPWtsAOyyCDEk/2C03mbf63ekf7LP6Iip0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1608761680159898.0495673803773; Wed, 23 Dec 2020 14:14:40 -0800 (PST) Received: from localhost ([::1]:35696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ksCP0-0006kU-Ux for importer@patchew.org; Wed, 23 Dec 2020 17:14:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ksCMB-0004iU-Fb for qemu-devel@nongnu.org; Wed, 23 Dec 2020 17:11:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ksCM5-0001x7-Qo for qemu-devel@nongnu.org; Wed, 23 Dec 2020 17:11:43 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-lm0dT7EEN2KhpxraZXXJzg-1; Wed, 23 Dec 2020 17:11:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20D56803622; Wed, 23 Dec 2020 22:11:33 +0000 (UTC) Received: from blue.redhat.com (ovpn-113-9.phx2.redhat.com [10.3.113.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0D5C5D74C; Wed, 23 Dec 2020 22:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608761497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9xmHO5fyVoINQziFIJJPHdUlbh8oTjbOt4cQUUkqO0w=; b=Tydpcg2hWvcUXndBS8GSljifLeg/r4hV1AXcoqdXjHcZYTRZt/2MiapC20P7SXoB1mA7l5 PmFAj02Ulsf+853RuifPXZtvScMiJe7xzLO6zedK0KEpbaF/UwgR6hioogmh5t2HoIKLrx vMWtC2su8PVbxupPeNWey2P4HZOG7P8= X-MC-Unique: lm0dT7EEN2KhpxraZXXJzg-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 7/7] qapi: More complex uses of QAPI_LIST_APPEND Date: Wed, 23 Dec 2020 16:11:02 -0600 Message-Id: <20201223221102.390740-8-eblake@redhat.com> In-Reply-To: <20201223221102.390740-1-eblake@redhat.com> References: <20201223221102.390740-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "open list:GLUSTER" , Eduardo Habkost , "open list:GLUSTER" , "Michael S. Tsirkin" , Michael Roth , Jason Wang , Juan Quintela , armbru@redhat.com, Max Reitz , Gerd Hoffmann , Igor Mammedov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/gluster.c | 13 ++---- block/qapi.c | 14 +----- dump/dump.c | 22 +++------ hw/core/machine-qmp-cmds.c | 93 ++++++++++++++++--------------------- hw/mem/memory-device.c | 12 +---- hw/pci/pci.c | 60 ++++++++---------------- migration/migration.c | 20 +++----- monitor/hmp-cmds.c | 25 ++++------ net/net.c | 13 +----- qga/commands-posix.c | 94 ++++++++++++++------------------------ qga/commands-win32.c | 88 ++++++++++++----------------------- softmmu/tpm.c | 38 +++------------ ui/spice-core.c | 27 ++++------- 13 files changed, 170 insertions(+), 349 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 1f8699b93835..e8ee14c8e9bf 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -514,7 +514,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlust= er *gconf, { QemuOpts *opts; SocketAddress *gsconf =3D NULL; - SocketAddressList *curr =3D NULL; + SocketAddressList **tail; QDict *backing_options =3D NULL; Error *local_err =3D NULL; char *str =3D NULL; @@ -547,6 +547,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlust= er *gconf, } gconf->path =3D g_strdup(ptr); qemu_opts_del(opts); + tail =3D &gconf->server; for (i =3D 0; i < num_servers; i++) { str =3D g_strdup_printf(GLUSTER_OPT_SERVER_PATTERN"%d.", i); @@ -655,15 +656,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlus= ter *gconf, qemu_opts_del(opts); } - if (gconf->server =3D=3D NULL) { - gconf->server =3D g_new0(SocketAddressList, 1); - gconf->server->value =3D gsconf; - curr =3D gconf->server; - } else { - curr->next =3D g_new0(SocketAddressList, 1); - curr->next->value =3D gsconf; - curr =3D curr->next; - } + QAPI_LIST_APPEND(tail, gsconf); gsconf =3D NULL; qobject_unref(backing_options); diff --git a/block/qapi.c b/block/qapi.c index 3a1186fdccf5..0a96099e36e2 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -198,7 +198,7 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs, { int i, sn_count; QEMUSnapshotInfo *sn_tab =3D NULL; - SnapshotInfoList *info_list, *cur_item =3D NULL, *head =3D NULL; + SnapshotInfoList *head =3D NULL, **tail =3D &head; SnapshotInfo *info; sn_count =3D bdrv_snapshot_list(bs, &sn_tab); @@ -233,17 +233,7 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs, info->icount =3D sn_tab[i].icount; info->has_icount =3D sn_tab[i].icount !=3D -1ULL; - info_list =3D g_new0(SnapshotInfoList, 1); - info_list->value =3D info; - - /* XXX: waiting for the qapi to support qemu-queue.h types */ - if (!cur_item) { - head =3D cur_item =3D info_list; - } else { - cur_item->next =3D info_list; - cur_item =3D info_list; - } - + QAPI_LIST_APPEND(tail, info); } g_free(sn_tab); diff --git a/dump/dump.c b/dump/dump.c index dec32468d98c..929138e91d08 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -2030,39 +2030,29 @@ void qmp_dump_guest_memory(bool paging, const char = *file, DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **= errp) { - DumpGuestMemoryFormatList *item; DumpGuestMemoryCapability *cap =3D g_malloc0(sizeof(DumpGuestMemoryCapabili= ty)); + DumpGuestMemoryFormatList **tail =3D &cap->formats; /* elf is always available */ - item =3D g_malloc0(sizeof(DumpGuestMemoryFormatList)); - cap->formats =3D item; - item->value =3D DUMP_GUEST_MEMORY_FORMAT_ELF; + QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_ELF); /* kdump-zlib is always available */ - item->next =3D g_malloc0(sizeof(DumpGuestMemoryFormatList)); - item =3D item->next; - item->value =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; + QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB); /* add new item if kdump-lzo is available */ #ifdef CONFIG_LZO - item->next =3D g_malloc0(sizeof(DumpGuestMemoryFormatList)); - item =3D item->next; - item->value =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; + QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO); #endif /* add new item if kdump-snappy is available */ #ifdef CONFIG_SNAPPY - item->next =3D g_malloc0(sizeof(DumpGuestMemoryFormatList)); - item =3D item->next; - item->value =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; + QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY); #endif /* Windows dump is available only if target is x86_64 */ #ifdef TARGET_X86_64 - item->next =3D g_malloc0(sizeof(DumpGuestMemoryFormatList)); - item =3D item->next; - item->value =3D DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; + QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_WIN_DMP); #endif return cap; diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 156223a344ed..44e979e503b1 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -28,11 +28,11 @@ CpuInfoList *qmp_query_cpus(Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(ms); - CpuInfoList *head =3D NULL, *cur_item =3D NULL; + CpuInfoList *head =3D NULL, **tail =3D &head; CPUState *cpu; CPU_FOREACH(cpu) { - CpuInfoList *info; + CpuInfo *value; #if defined(TARGET_I386) X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; @@ -58,53 +58,46 @@ CpuInfoList *qmp_query_cpus(Error **errp) cpu_synchronize_state(cpu); - info =3D g_malloc0(sizeof(*info)); - info->value =3D g_malloc0(sizeof(*info->value)); - info->value->CPU =3D cpu->cpu_index; - info->value->current =3D (cpu =3D=3D first_cpu); - info->value->halted =3D cpu->halted; - info->value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); - info->value->thread_id =3D cpu->thread_id; + value =3D g_malloc0(sizeof(*value)); + value->CPU =3D cpu->cpu_index; + value->current =3D (cpu =3D=3D first_cpu); + value->halted =3D cpu->halted; + value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); + value->thread_id =3D cpu->thread_id; #if defined(TARGET_I386) - info->value->arch =3D CPU_INFO_ARCH_X86; - info->value->u.x86.pc =3D env->eip + env->segs[R_CS].base; + value->arch =3D CPU_INFO_ARCH_X86; + value->u.x86.pc =3D env->eip + env->segs[R_CS].base; #elif defined(TARGET_PPC) - info->value->arch =3D CPU_INFO_ARCH_PPC; - info->value->u.ppc.nip =3D env->nip; + value->arch =3D CPU_INFO_ARCH_PPC; + value->u.ppc.nip =3D env->nip; #elif defined(TARGET_SPARC) - info->value->arch =3D CPU_INFO_ARCH_SPARC; - info->value->u.q_sparc.pc =3D env->pc; - info->value->u.q_sparc.npc =3D env->npc; + value->arch =3D CPU_INFO_ARCH_SPARC; + value->u.q_sparc.pc =3D env->pc; + value->u.q_sparc.npc =3D env->npc; #elif defined(TARGET_MIPS) - info->value->arch =3D CPU_INFO_ARCH_MIPS; - info->value->u.q_mips.PC =3D env->active_tc.PC; + value->arch =3D CPU_INFO_ARCH_MIPS; + value->u.q_mips.PC =3D env->active_tc.PC; #elif defined(TARGET_TRICORE) - info->value->arch =3D CPU_INFO_ARCH_TRICORE; - info->value->u.tricore.PC =3D env->PC; + value->arch =3D CPU_INFO_ARCH_TRICORE; + value->u.tricore.PC =3D env->PC; #elif defined(TARGET_S390X) - info->value->arch =3D CPU_INFO_ARCH_S390; - info->value->u.s390.cpu_state =3D env->cpu_state; + value->arch =3D CPU_INFO_ARCH_S390; + value->u.s390.cpu_state =3D env->cpu_state; #elif defined(TARGET_RISCV) - info->value->arch =3D CPU_INFO_ARCH_RISCV; - info->value->u.riscv.pc =3D env->pc; + value->arch =3D CPU_INFO_ARCH_RISCV; + value->u.riscv.pc =3D env->pc; #else - info->value->arch =3D CPU_INFO_ARCH_OTHER; + value->arch =3D CPU_INFO_ARCH_OTHER; #endif - info->value->has_props =3D !!mc->cpu_index_to_instance_props; - if (info->value->has_props) { + value->has_props =3D !!mc->cpu_index_to_instance_props; + if (value->has_props) { CpuInstanceProperties *props; props =3D g_malloc0(sizeof(*props)); *props =3D mc->cpu_index_to_instance_props(ms, cpu->cpu_index); - info->value->props =3D props; + value->props =3D props; } - /* XXX: waiting for the qapi to support GSList */ - if (!cur_item) { - head =3D cur_item =3D info; - } else { - cur_item->next =3D info; - cur_item =3D info; - } + QAPI_LIST_APPEND(tail, value); } return head; @@ -170,39 +163,33 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(ms); - CpuInfoFastList *head =3D NULL, *cur_item =3D NULL; + CpuInfoFastList *head =3D NULL, **tail =3D &head; SysEmuTarget target =3D qapi_enum_parse(&SysEmuTarget_lookup, TARGET_N= AME, -1, &error_abort); CPUState *cpu; CPU_FOREACH(cpu) { - CpuInfoFastList *info =3D g_malloc0(sizeof(*info)); - info->value =3D g_malloc0(sizeof(*info->value)); + CpuInfoFast *value =3D g_malloc0(sizeof(*value)); - info->value->cpu_index =3D cpu->cpu_index; - info->value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); - info->value->thread_id =3D cpu->thread_id; + value->cpu_index =3D cpu->cpu_index; + value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); + value->thread_id =3D cpu->thread_id; - info->value->has_props =3D !!mc->cpu_index_to_instance_props; - if (info->value->has_props) { + value->has_props =3D !!mc->cpu_index_to_instance_props; + if (value->has_props) { CpuInstanceProperties *props; props =3D g_malloc0(sizeof(*props)); *props =3D mc->cpu_index_to_instance_props(ms, cpu->cpu_index); - info->value->props =3D props; + value->props =3D props; } - info->value->arch =3D sysemu_target_to_cpuinfo_arch(target); - info->value->target =3D target; + value->arch =3D sysemu_target_to_cpuinfo_arch(target); + value->target =3D target; if (target =3D=3D SYS_EMU_TARGET_S390X) { - cpustate_to_cpuinfo_s390(&info->value->u.s390x, cpu); + cpustate_to_cpuinfo_s390(&value->u.s390x, cpu); } - if (!cur_item) { - head =3D cur_item =3D info; - } else { - cur_item->next =3D info; - cur_item =3D info; - } + QAPI_LIST_APPEND(tail, value); } return head; diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index cf0627fd01c1..d9f8301711e2 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 =3D NULL, *item; - MemoryDeviceInfoList *list =3D NULL, *prev =3D NULL; + MemoryDeviceInfoList *list =3D NULL, **tail =3D &list; object_child_foreach(qdev_get_machine(), memory_device_build_list, &devices); @@ -207,19 +207,11 @@ MemoryDeviceInfoList *qmp_memory_device_list(void) for (item =3D devices; item; item =3D g_slist_next(item)) { const MemoryDeviceState *md =3D MEMORY_DEVICE(item->data); const MemoryDeviceClass *mdc =3D MEMORY_DEVICE_GET_CLASS(item->dat= a); - MemoryDeviceInfoList *elem =3D g_new0(MemoryDeviceInfoList, 1); MemoryDeviceInfo *info =3D g_new0(MemoryDeviceInfo, 1); mdc->fill_device_info(md, info); - elem->value =3D info; - elem->next =3D NULL; - if (prev) { - prev->next =3D elem; - } else { - list =3D elem; - } - prev =3D elem; + QAPI_LIST_APPEND(tail, info); } g_slist_free(devices); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index d4349ea57765..0d99fe03b98b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1682,41 +1682,34 @@ static PciDeviceInfoList *qmp_query_pci_devices(PCI= Bus *bus, int bus_num); static PciMemoryRegionList *qmp_query_pci_regions(const PCIDevice *dev) { - PciMemoryRegionList *head =3D NULL, *cur_item =3D NULL; + PciMemoryRegionList *head =3D NULL, **tail =3D &head; int i; for (i =3D 0; i < PCI_NUM_REGIONS; i++) { const PCIIORegion *r =3D &dev->io_regions[i]; - PciMemoryRegionList *region; + PciMemoryRegion *region; if (!r->size) { continue; } region =3D g_malloc0(sizeof(*region)); - region->value =3D g_malloc0(sizeof(*region->value)); if (r->type & PCI_BASE_ADDRESS_SPACE_IO) { - region->value->type =3D g_strdup("io"); + region->type =3D g_strdup("io"); } else { - region->value->type =3D g_strdup("memory"); - region->value->has_prefetch =3D true; - region->value->prefetch =3D !!(r->type & PCI_BASE_ADDRESS_MEM_= PREFETCH); - region->value->has_mem_type_64 =3D true; - region->value->mem_type_64 =3D !!(r->type & PCI_BASE_ADDRESS_M= EM_TYPE_64); + region->type =3D g_strdup("memory"); + region->has_prefetch =3D true; + region->prefetch =3D !!(r->type & PCI_BASE_ADDRESS_MEM_PREFETC= H); + region->has_mem_type_64 =3D true; + region->mem_type_64 =3D !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE= _64); } - region->value->bar =3D i; - region->value->address =3D r->addr; - region->value->size =3D r->size; + region->bar =3D i; + region->address =3D r->addr; + region->size =3D r->size; - /* XXX: waiting for the qapi to support GSList */ - if (!cur_item) { - head =3D cur_item =3D region; - } else { - cur_item->next =3D region; - cur_item =3D region; - } + QAPI_LIST_APPEND(tail, region); } return head; @@ -1813,23 +1806,14 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevic= e *dev, PCIBus *bus, static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num) { - PciDeviceInfoList *info, *head =3D NULL, *cur_item =3D NULL; + PciDeviceInfoList *head =3D NULL, **tail =3D &head; PCIDevice *dev; int devfn; for (devfn =3D 0; devfn < ARRAY_SIZE(bus->devices); devfn++) { dev =3D bus->devices[devfn]; if (dev) { - info =3D g_malloc0(sizeof(*info)); - info->value =3D qmp_query_pci_device(dev, bus, bus_num); - - /* XXX: waiting for the qapi to support GSList */ - if (!cur_item) { - head =3D cur_item =3D info; - } else { - cur_item->next =3D info; - cur_item =3D info; - } + QAPI_LIST_APPEND(tail, qmp_query_pci_device(dev, bus, bus_num)= ); } } @@ -1852,21 +1836,13 @@ static PciInfo *qmp_query_pci_bus(PCIBus *bus, int = bus_num) PciInfoList *qmp_query_pci(Error **errp) { - PciInfoList *info, *head =3D NULL, *cur_item =3D NULL; + PciInfoList *head =3D NULL, **tail =3D &head; PCIHostState *host_bridge; QLIST_FOREACH(host_bridge, &pci_host_bridges, next) { - info =3D g_malloc0(sizeof(*info)); - info->value =3D qmp_query_pci_bus(host_bridge->bus, - pci_bus_num(host_bridge->bus)); - - /* XXX: waiting for the qapi to support GSList */ - if (!cur_item) { - head =3D cur_item =3D info; - } else { - cur_item->next =3D info; - cur_item =3D info; - } + QAPI_LIST_APPEND(tail, + qmp_query_pci_bus(host_bridge->bus, + pci_bus_num(host_bridge->bus))); } return head; diff --git a/migration/migration.c b/migration/migration.c index 805712488e4d..a676405019d1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -784,29 +784,21 @@ void migrate_send_rp_resume_ack(MigrationIncomingStat= e *mis, uint32_t value) MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) { - MigrationCapabilityStatusList *head =3D NULL; - MigrationCapabilityStatusList *caps; + MigrationCapabilityStatusList *head =3D NULL, **tail =3D &head; + MigrationCapabilityStatus *caps; MigrationState *s =3D migrate_get_current(); int i; - caps =3D NULL; /* silence compiler warning */ for (i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { #ifndef CONFIG_LIVE_BLOCK_MIGRATION if (i =3D=3D MIGRATION_CAPABILITY_BLOCK) { continue; } #endif - if (head =3D=3D NULL) { - head =3D g_malloc0(sizeof(*caps)); - caps =3D head; - } else { - caps->next =3D g_malloc0(sizeof(*caps)); - caps =3D caps->next; - } - caps->value =3D - g_malloc(sizeof(*caps->value)); - caps->value->capability =3D i; - caps->value->state =3D s->enabled_capabilities[i]; + caps =3D g_malloc(sizeof(*caps)); + caps->capability =3D i; + caps->state =3D s->enabled_capabilities[i]; + QAPI_LIST_APPEND(tail, caps); } return head; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index ed4131efbca6..a9643ff41961 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1705,7 +1705,8 @@ void hmp_closefd(Monitor *mon, const QDict *qdict) void hmp_sendkey(Monitor *mon, const QDict *qdict) { const char *keys =3D qdict_get_str(qdict, "keys"); - KeyValueList *keylist, *head =3D NULL, *tmp =3D NULL; + KeyValue *v =3D NULL; + KeyValueList *head =3D NULL, **tail =3D &head; int has_hold_time =3D qdict_haskey(qdict, "hold-time"); int hold_time =3D qdict_get_try_int(qdict, "hold-time", -1); Error *err =3D NULL; @@ -1722,16 +1723,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) keyname_len =3D 4; } - keylist =3D g_malloc0(sizeof(*keylist)); - keylist->value =3D g_malloc0(sizeof(*keylist->value)); - - if (!head) { - head =3D keylist; - } - if (tmp) { - tmp->next =3D keylist; - } - tmp =3D keylist; + v =3D g_malloc0(sizeof(*v)); if (strstart(keys, "0x", NULL)) { char *endp; @@ -1740,16 +1732,18 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) if (endp !=3D keys + keyname_len) { goto err_out; } - keylist->value->type =3D KEY_VALUE_KIND_NUMBER; - keylist->value->u.number.data =3D value; + v->type =3D KEY_VALUE_KIND_NUMBER; + v->u.number.data =3D value; } else { int idx =3D index_from_key(keys, keyname_len); if (idx =3D=3D Q_KEY_CODE__MAX) { goto err_out; } - keylist->value->type =3D KEY_VALUE_KIND_QCODE; - keylist->value->u.qcode.data =3D idx; + v->type =3D KEY_VALUE_KIND_QCODE; + v->u.qcode.data =3D idx; } + QAPI_LIST_APPEND(tail, v); + v =3D NULL; if (!*separator) { break; @@ -1761,6 +1755,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); out: + qapi_free_KeyValue(v); qapi_free_KeyValueList(head); return; diff --git a/net/net.c b/net/net.c index e581c8a26868..c7e8f4bc403c 100644 --- a/net/net.c +++ b/net/net.c @@ -1197,10 +1197,9 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name,= const char *name, Error **errp) { NetClientState *nc; - RxFilterInfoList *filter_list =3D NULL, *last_entry =3D NULL; + RxFilterInfoList *filter_list =3D NULL, **tail =3D &filter_list; QTAILQ_FOREACH(nc, &net_clients, next) { - RxFilterInfoList *entry; RxFilterInfo *info; if (has_name && strcmp(nc->name, name) !=3D 0) { @@ -1225,15 +1224,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name,= const char *name, if (nc->info->query_rx_filter) { info =3D nc->info->query_rx_filter(nc); - entry =3D g_malloc0(sizeof(*entry)); - entry->value =3D info; - - if (!filter_list) { - filter_list =3D entry; - } else { - last_entry->next =3D entry; - } - last_entry =3D entry; + QAPI_LIST_APPEND(tail, info); } else if (has_name) { error_setg(errp, "net client(%s) doesn't support" " rx-filter querying", name); diff --git a/qga/commands-posix.c b/qga/commands-posix.c index a5058a3bd15e..10ee740eee1b 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2119,17 +2119,17 @@ void qmp_guest_suspend_hybrid(Error **errp) guest_suspend(SUSPEND_MODE_HYBRID, errp); } -static GuestNetworkInterfaceList * +static GuestNetworkInterface * guest_find_interface(GuestNetworkInterfaceList *head, const char *name) { for (; head; head =3D head->next) { if (strcmp(head->value->name, name) =3D=3D 0) { - break; + return head->value; } } - return head; + return NULL; } static int guest_get_network_stats(const char *name, @@ -2198,7 +2198,7 @@ static int guest_get_network_stats(const char *name, */ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) { - GuestNetworkInterfaceList *head =3D NULL, *cur_item =3D NULL; + GuestNetworkInterfaceList *head =3D NULL, **tail =3D &head; struct ifaddrs *ifap, *ifa; if (getifaddrs(&ifap) < 0) { @@ -2207,9 +2207,10 @@ GuestNetworkInterfaceList *qmp_guest_network_get_int= erfaces(Error **errp) } for (ifa =3D ifap; ifa; ifa =3D ifa->ifa_next) { - GuestNetworkInterfaceList *info; - GuestIpAddressList **address_list =3D NULL, *address_item =3D NULL; - GuestNetworkInterfaceStat *interface_stat =3D NULL; + GuestNetworkInterface *info; + GuestIpAddressList **address_tail; + GuestIpAddress *address_item =3D NULL; + GuestNetworkInterfaceStat *interface_stat =3D NULL; char addr4[INET_ADDRSTRLEN]; char addr6[INET6_ADDRSTRLEN]; int sock; @@ -2223,19 +2224,14 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) if (!info) { info =3D g_malloc0(sizeof(*info)); - info->value =3D g_malloc0(sizeof(*info->value)); - info->value->name =3D g_strdup(ifa->ifa_name); + info->name =3D g_strdup(ifa->ifa_name); - if (!cur_item) { - head =3D cur_item =3D info; - } else { - cur_item->next =3D info; - cur_item =3D info; - } + QAPI_LIST_APPEND(tail, info); } - if (!info->value->has_hardware_address && - ifa->ifa_flags & SIOCGIFHWADDR) { + address_tail =3D &info->ip_addresses; + + if (!info->has_hardware_address && ifa->ifa_flags & SIOCGIFHWADDR)= { /* we haven't obtained HW address yet */ sock =3D socket(PF_INET, SOCK_STREAM, 0); if (sock =3D=3D -1) { @@ -2244,7 +2240,7 @@ GuestNetworkInterfaceList *qmp_guest_network_get_inte= rfaces(Error **errp) } memset(&ifr, 0, sizeof(ifr)); - pstrcpy(ifr.ifr_name, IF_NAMESIZE, info->value->name); + pstrcpy(ifr.ifr_name, IF_NAMESIZE, info->name); if (ioctl(sock, SIOCGIFHWADDR, &ifr) =3D=3D -1) { error_setg_errno(errp, errno, "failed to get MAC address of %s", @@ -2256,13 +2252,13 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) close(sock); mac_addr =3D (unsigned char *) &ifr.ifr_hwaddr.sa_data; - info->value->hardware_address =3D + info->hardware_address =3D g_strdup_printf("%02x:%02x:%02x:%02x:%02x:%02x", (int) mac_addr[0], (int) mac_addr[1], (int) mac_addr[2], (int) mac_addr[3], (int) mac_addr[4], (int) mac_addr[5]); - info->value->has_hardware_address =3D true; + info->has_hardware_address =3D true; } if (ifa->ifa_addr && @@ -2275,15 +2271,14 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) } address_item =3D g_malloc0(sizeof(*address_item)); - address_item->value =3D g_malloc0(sizeof(*address_item->value)= ); - address_item->value->ip_address =3D g_strdup(addr4); - address_item->value->ip_address_type =3D GUEST_IP_ADDRESS_TYPE= _IPV4; + address_item->ip_address =3D g_strdup(addr4); + address_item->ip_address_type =3D GUEST_IP_ADDRESS_TYPE_IPV4; if (ifa->ifa_netmask) { /* Count the number of set bits in netmask. * This is safe as '1' and '0' cannot be shuffled in netma= sk. */ p =3D &((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr; - address_item->value->prefix =3D ctpop32(((uint32_t *) p)[0= ]); + address_item->prefix =3D ctpop32(((uint32_t *) p)[0]); } } else if (ifa->ifa_addr && ifa->ifa_addr->sa_family =3D=3D AF_INET6) { @@ -2295,15 +2290,14 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) } address_item =3D g_malloc0(sizeof(*address_item)); - address_item->value =3D g_malloc0(sizeof(*address_item->value)= ); - address_item->value->ip_address =3D g_strdup(addr6); - address_item->value->ip_address_type =3D GUEST_IP_ADDRESS_TYPE= _IPV6; + address_item->ip_address =3D g_strdup(addr6); + address_item->ip_address_type =3D GUEST_IP_ADDRESS_TYPE_IPV6; if (ifa->ifa_netmask) { /* Count the number of set bits in netmask. * This is safe as '1' and '0' cannot be shuffled in netma= sk. */ p =3D &((struct sockaddr_in6 *)ifa->ifa_netmask)->sin6_add= r; - address_item->value->prefix =3D + address_item->prefix =3D ctpop32(((uint32_t *) p)[0]) + ctpop32(((uint32_t *) p)[1]) + ctpop32(((uint32_t *) p)[2]) + @@ -2315,29 +2309,18 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) continue; } - address_list =3D &info->value->ip_addresses; + QAPI_LIST_APPEND(address_tail, address_item); - while (*address_list && (*address_list)->next) { - address_list =3D &(*address_list)->next; - } + info->has_ip_addresses =3D true; - if (!*address_list) { - *address_list =3D address_item; - } else { - (*address_list)->next =3D address_item; - } - - info->value->has_ip_addresses =3D true; - - if (!info->value->has_statistics) { + if (!info->has_statistics) { interface_stat =3D g_malloc0(sizeof(*interface_stat)); - if (guest_get_network_stats(info->value->name, - interface_stat) =3D=3D -1) { - info->value->has_statistics =3D false; + if (guest_get_network_stats(info->name, interface_stat) =3D=3D= -1) { + info->has_statistics =3D false; g_free(interface_stat); } else { - info->value->statistics =3D interface_stat; - info->value->has_statistics =3D true; + info->statistics =3D interface_stat; + info->has_statistics =3D true; } } } @@ -3104,11 +3087,10 @@ static double ga_get_login_time(struct utmpx *user_= info) GuestUserList *qmp_guest_get_users(Error **errp) { GHashTable *cache =3D NULL; - GuestUserList *head =3D NULL, *cur_item =3D NULL; + GuestUserList *head =3D NULL, **tail =3D &head; struct utmpx *user_info =3D NULL; gpointer value =3D NULL; GuestUser *user =3D NULL; - GuestUserList *item =3D NULL; double login_time =3D 0; cache =3D g_hash_table_new(g_str_hash, g_str_equal); @@ -3131,19 +3113,13 @@ GuestUserList *qmp_guest_get_users(Error **errp) continue; } - item =3D g_new0(GuestUserList, 1); - item->value =3D g_new0(GuestUser, 1); - item->value->user =3D g_strdup(user_info->ut_user); - item->value->login_time =3D ga_get_login_time(user_info); + user =3D g_new0(GuestUser, 1); + user->user =3D g_strdup(user_info->ut_user); + user->login_time =3D ga_get_login_time(user_info); - g_hash_table_insert(cache, item->value->user, item->value); + g_hash_table_insert(cache, user->user, user); - if (!cur_item) { - head =3D cur_item =3D item; - } else { - cur_item->next =3D item; - cur_item =3D item; - } + QAPI_LIST_APPEND(tail, user); } endutxent(); g_hash_table_destroy(cache); diff --git a/qga/commands-win32.c b/qga/commands-win32.c index a6cc481bc356..a00e6cb16557 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -1624,11 +1624,11 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) { IP_ADAPTER_ADDRESSES *adptr_addrs, *addr; IP_ADAPTER_UNICAST_ADDRESS *ip_addr =3D NULL; - GuestNetworkInterfaceList *head =3D NULL, *cur_item =3D NULL; - GuestIpAddressList *head_addr, *cur_addr; - GuestNetworkInterfaceList *info; + GuestNetworkInterfaceList *head =3D NULL, **tail =3D &head; + GuestIpAddressList *head_addr, **tail_addr; + GuestNetworkInterface *info; GuestNetworkInterfaceStat *interface_stat =3D NULL; - GuestIpAddressList *address_item =3D NULL; + GuestIpAddress *address_item =3D NULL; unsigned char *mac_addr; char *addr_str; WORD wsa_version; @@ -1651,30 +1651,24 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) for (addr =3D adptr_addrs; addr; addr =3D addr->Next) { info =3D g_malloc0(sizeof(*info)); - if (cur_item =3D=3D NULL) { - head =3D cur_item =3D info; - } else { - cur_item->next =3D info; - cur_item =3D info; - } + QAPI_LIST_APPEND(tail, info); - info->value =3D g_malloc0(sizeof(*info->value)); - info->value->name =3D guest_wctomb_dup(addr->FriendlyName); + info->name =3D guest_wctomb_dup(addr->FriendlyName); if (addr->PhysicalAddressLength !=3D 0) { mac_addr =3D addr->PhysicalAddress; - info->value->hardware_address =3D + info->hardware_address =3D g_strdup_printf("%02x:%02x:%02x:%02x:%02x:%02x", (int) mac_addr[0], (int) mac_addr[1], (int) mac_addr[2], (int) mac_addr[3], (int) mac_addr[4], (int) mac_addr[5]); - info->value->has_hardware_address =3D true; + info->has_hardware_address =3D true; } head_addr =3D NULL; - cur_addr =3D NULL; + tail_addr =3D &head_addr; for (ip_addr =3D addr->FirstUnicastAddress; ip_addr; ip_addr =3D ip_addr->Next) { @@ -1685,37 +1679,29 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) address_item =3D g_malloc0(sizeof(*address_item)); - if (!cur_addr) { - head_addr =3D cur_addr =3D address_item; - } else { - cur_addr->next =3D address_item; - cur_addr =3D address_item; - } + QAPI_LIST_APPEND(tail_addr, address_item); - address_item->value =3D g_malloc0(sizeof(*address_item->value)= ); - address_item->value->ip_address =3D addr_str; - address_item->value->prefix =3D guest_ip_prefix(ip_addr); + address_item->ip_address =3D addr_str; + address_item->prefix =3D guest_ip_prefix(ip_addr); if (ip_addr->Address.lpSockaddr->sa_family =3D=3D AF_INET) { - address_item->value->ip_address_type =3D - GUEST_IP_ADDRESS_TYPE_IPV4; + address_item->ip_address_type =3D GUEST_IP_ADDRESS_TYPE_IP= V4; } else if (ip_addr->Address.lpSockaddr->sa_family =3D=3D AF_IN= ET6) { - address_item->value->ip_address_type =3D - GUEST_IP_ADDRESS_TYPE_IPV6; + address_item->ip_address_type =3D GUEST_IP_ADDRESS_TYPE_IP= V6; } } if (head_addr) { - info->value->has_ip_addresses =3D true; - info->value->ip_addresses =3D head_addr; + info->has_ip_addresses =3D true; + info->ip_addresses =3D head_addr; } - if (!info->value->has_statistics) { + if (!info->has_statistics) { interface_stat =3D g_malloc0(sizeof(*interface_stat)); if (guest_get_network_stats(addr->AdapterName, interface_stat) =3D=3D -1) { - info->value->has_statistics =3D false; + info->has_statistics =3D false; g_free(interface_stat); } else { - info->value->statistics =3D interface_stat; - info->value->has_statistics =3D true; + info->statistics =3D interface_stat; + info->has_statistics =3D true; } } } @@ -2082,12 +2068,11 @@ GuestUserList *qmp_guest_get_users(Error **errp) #define QGA_NANOSECONDS 10000000 GHashTable *cache =3D NULL; - GuestUserList *head =3D NULL, *cur_item =3D NULL; + GuestUserList *head =3D NULL, **tail =3D &head; DWORD buffer_size =3D 0, count =3D 0, i =3D 0; GA_WTSINFOA *info =3D NULL; WTS_SESSION_INFOA *entries =3D NULL; - GuestUserList *item =3D NULL; GuestUser *user =3D NULL; gpointer value =3D NULL; INT64 login =3D 0; @@ -2123,23 +2108,17 @@ GuestUserList *qmp_guest_get_users(Error **errp) user->login_time =3D login_time; } } else { - item =3D g_new0(GuestUserList, 1); - item->value =3D g_new0(GuestUser, 1); + user =3D g_new0(GuestUser, 1); - item->value->user =3D g_strdup(info->UserName); - item->value->domain =3D g_strdup(info->Domain); - item->value->has_domain =3D true; + user->user =3D g_strdup(info->UserName); + user->domain =3D g_strdup(info->Domain); + user->has_domain =3D true; - item->value->login_time =3D login_time; + user->login_time =3D login_time; - g_hash_table_add(cache, item->value->user); + g_hash_table_add(cache, user->user); - if (!cur_item) { - head =3D cur_item =3D item; - } else { - cur_item->next =3D item; - cur_item =3D item; - } + QAPI_LIST_APPEND(tail, user); } } WTSFreeMemory(info); @@ -2424,7 +2403,7 @@ static GStrv ga_get_hardware_ids(DEVINST devInstance) GuestDeviceInfoList *qmp_guest_get_devices(Error **errp) { - GuestDeviceInfoList *head =3D NULL, *cur_item =3D NULL, *item =3D NULL; + GuestDeviceInfoList *head =3D NULL, **tail =3D &head; HDEVINFO dev_info =3D INVALID_HANDLE_VALUE; SP_DEVINFO_DATA dev_info_data; int i, j; @@ -2522,14 +2501,7 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error **e= rrp) slog("driver: %s\ndriver version: %" PRId64 ",%s\n", device->driver_name, device->driver_date, device->driver_version); - item =3D g_new0(GuestDeviceInfoList, 1); - item->value =3D g_steal_pointer(&device); - if (!cur_item) { - head =3D cur_item =3D item; - } else { - cur_item->next =3D item; - cur_item =3D item; - } + QAPI_LIST_APPEND(tail, g_steal_pointer(&device)); } if (dev_info !=3D INVALID_HANDLE_VALUE) { diff --git a/softmmu/tpm.c b/softmmu/tpm.c index cab206355afd..578563f05a7b 100644 --- a/softmmu/tpm.c +++ b/softmmu/tpm.c @@ -196,22 +196,14 @@ int tpm_config_parse(QemuOptsList *opts_list, const c= har *optarg) TPMInfoList *qmp_query_tpm(Error **errp) { TPMBackend *drv; - TPMInfoList *info, *head =3D NULL, *cur_item =3D NULL; + TPMInfoList *head =3D NULL, **tail =3D &head; QLIST_FOREACH(drv, &tpm_backends, list) { if (!drv->tpmif) { continue; } - info =3D g_new0(TPMInfoList, 1); - info->value =3D tpm_backend_query_tpm(drv); - - if (!cur_item) { - head =3D cur_item =3D info; - } else { - cur_item->next =3D info; - cur_item =3D info; - } + QAPI_LIST_APPEND(tail, tpm_backend_query_tpm(drv)); } return head; @@ -220,44 +212,26 @@ TPMInfoList *qmp_query_tpm(Error **errp) TpmTypeList *qmp_query_tpm_types(Error **errp) { unsigned int i =3D 0; - TpmTypeList *head =3D NULL, *prev =3D NULL, *cur_item; + TpmTypeList *head =3D NULL, **tail =3D &head; for (i =3D 0; i < TPM_TYPE__MAX; i++) { if (!tpm_be_find_by_type(i)) { continue; } - cur_item =3D g_new0(TpmTypeList, 1); - cur_item->value =3D i; - - if (prev) { - prev->next =3D cur_item; - } - if (!head) { - head =3D cur_item; - } - prev =3D cur_item; + QAPI_LIST_APPEND(tail, i); } return head; } TpmModelList *qmp_query_tpm_models(Error **errp) { - TpmModelList *head =3D NULL, *prev =3D NULL, *cur_item; + TpmModelList *head =3D NULL, **tail =3D &head; GSList *e, *l =3D object_class_get_list(TYPE_TPM_IF, false); for (e =3D l; e; e =3D e->next) { TPMIfClass *c =3D TPM_IF_CLASS(e->data); - cur_item =3D g_new0(TpmModelList, 1); - cur_item->value =3D c->model; - - if (prev) { - prev->next =3D cur_item; - } - if (!head) { - head =3D cur_item; - } - prev =3D cur_item; + QAPI_LIST_APPEND(tail, c->model); } g_slist_free(l); diff --git a/ui/spice-core.c b/ui/spice-core.c index eea52f538999..58232b649e60 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -355,11 +355,11 @@ static const char *wan_compression_names[] =3D { static SpiceChannelList *qmp_query_spice_channels(void) { - SpiceChannelList *cur_item =3D NULL, *head =3D NULL; + SpiceChannelList *head =3D NULL, **tail =3D &head; ChannelList *item; QTAILQ_FOREACH(item, &channel_list, link) { - SpiceChannelList *chan; + SpiceChannel *chan; char host[NI_MAXHOST], port[NI_MAXSERV]; struct sockaddr *paddr; socklen_t plen; @@ -367,29 +367,22 @@ static SpiceChannelList *qmp_query_spice_channels(voi= d) assert(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT); chan =3D g_malloc0(sizeof(*chan)); - chan->value =3D g_malloc0(sizeof(*chan->value)); paddr =3D (struct sockaddr *)&item->info->paddr_ext; plen =3D item->info->plen_ext; getnameinfo(paddr, plen, host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); - chan->value->host =3D g_strdup(host); - chan->value->port =3D g_strdup(port); - chan->value->family =3D inet_netfamily(paddr->sa_family); + chan->host =3D g_strdup(host); + chan->port =3D g_strdup(port); + chan->family =3D inet_netfamily(paddr->sa_family); - chan->value->connection_id =3D item->info->connection_id; - chan->value->channel_type =3D item->info->type; - chan->value->channel_id =3D item->info->id; - chan->value->tls =3D item->info->flags & SPICE_CHANNEL_EVENT_FLAG_= TLS; + chan->connection_id =3D item->info->connection_id; + chan->channel_type =3D item->info->type; + chan->channel_id =3D item->info->id; + chan->tls =3D item->info->flags & SPICE_CHANNEL_EVENT_FLAG_TLS; - /* XXX: waiting for the qapi to support GSList */ - if (!cur_item) { - head =3D cur_item =3D chan; - } else { - cur_item->next =3D chan; - cur_item =3D chan; - } + QAPI_LIST_APPEND(tail, chan); } return head; --=20 2.29.2