From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kzg1K-0003qK-Dk for mharc-qemu-trivial@gnu.org; Wed, 13 Jan 2021 08:17:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzg1G-0003oI-I3 for qemu-trivial@nongnu.org; Wed, 13 Jan 2021 08:17:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kzg1C-0007c1-0i for qemu-trivial@nongnu.org; Wed, 13 Jan 2021 08:17:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610543814; 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: in-reply-to:in-reply-to:references:references; bh=bK15k+xdC4A0Up4JkR6Lu7Rifjs8QZM7pyf/z0RA6aM=; b=XtGVBB3OrA6WuVPYAebdELjhPbtRI+Sr4TaS1AA2s59ezFTlzitOwv/ZYd8N/yLec0KYKx xQPcKftFbaL1uU4lMzdUUZ4Sgjzjlgz1yj4Nj46OKScn/ixJ6gSUUrIXetGpjWebUT9B3v oP6xKyVdI7ejkkOiGltqwVRaezeMGYI= 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-192-JYKNl7sSP0ifdoqRF6OHdw-1; Wed, 13 Jan 2021 08:16:53 -0500 X-MC-Unique: JYKNl7sSP0ifdoqRF6OHdw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8DB21005D44; Wed, 13 Jan 2021 13:16:51 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51E2360BF1; Wed, 13 Jan 2021 13:16:48 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CB1DA11386A7; Wed, 13 Jan 2021 14:16:46 +0100 (CET) From: Markus Armbruster To: Eric Blake Cc: qemu-devel@nongnu.org, Kevin Wolf , Fam Zheng , Vladimir Sementsov-Ogievskiy , Daniel P. =?utf-8?Q?Berrang=C3=A9?= , Eduardo Habkost , "open list:Dirty Bitmaps" , "Michael S. Tsirkin" , "open list:Trivial patches" , Michael Roth , Richard Henderson , Max Reitz , Michael Tokarev , Paolo Bonzini , Igor Mammedov , John Snow , "Dr. David Alan Gilbert" , Laurent Vivier Subject: Re: [PATCH v3 6/7] qapi: Use QAPI_LIST_APPEND in trivial cases References: <20201223221102.390740-1-eblake@redhat.com> <20201223221102.390740-7-eblake@redhat.com> Date: Wed, 13 Jan 2021 14:16:46 +0100 In-Reply-To: <20201223221102.390740-7-eblake@redhat.com> (Eric Blake's message of "Wed, 23 Dec 2020 16:11:01 -0600") Message-ID: <87v9c1yo1t.fsf@dusky.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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-trivial@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 13:17:03 -0000 Eric Blake writes: > 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 > --- [...] > diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c > index 6350caa76530..3f3182007b07 100644 > --- a/hw/acpi/cpu.c > +++ b/hw/acpi/cpu.c > @@ -42,16 +42,12 @@ static ACPIOSTInfo *acpi_cpu_device_status(int idx, AcpiCpuStatus *cdev) > return info; > } > > -void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list) > +void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***tail) > { > int i; Sure you want to rename the parameter? What about: void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list) { + ACPIOSTInfoList ***tail = list; int i; > > for (i = 0; i < cpu_st->dev_count; i++) { > - ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1); > - elem->value = acpi_cpu_device_status(i, &cpu_st->devs[i]); > - elem->next = NULL; > - **list = elem; > - *list = &elem->next; > + QAPI_LIST_APPEND(*tail, acpi_cpu_device_status(i, &cpu_st->devs[i])); > } > } > > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c > index f2552b2a4624..e4b836bd5e46 100644 > --- a/hw/acpi/memory_hotplug.c > +++ b/hw/acpi/memory_hotplug.c > @@ -51,16 +51,13 @@ static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) > return info; > } > > -void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list) > +void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***tail) Likewise. > { > int i; > > for (i = 0; i < mem_st->dev_count; i++) { > - ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1); > - elem->value = acpi_memory_device_status(i, &mem_st->devs[i]); > - elem->next = NULL; > - **list = elem; > - *list = &elem->next; > + QAPI_LIST_APPEND(*tail, > + acpi_memory_device_status(i, &mem_st->devs[i])); > } > } > [...] > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index 35459a38bb1c..95326285b76d 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -4817,20 +4817,17 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose); > > /* Build a list with the name of all features on a feature word array */ > static void x86_cpu_list_feature_names(FeatureWordArray features, > - strList **feat_names) > + strList **tail) Likewise. > { > FeatureWord w; > - strList **next = feat_names; > > for (w = 0; w < FEATURE_WORDS; w++) { > uint64_t filtered = features[w]; > int i; > for (i = 0; i < 64; i++) { > if (filtered & (1ULL << i)) { > - strList *new = g_new0(strList, 1); > - new->value = g_strdup(x86_cpu_feature_name(w, i)); > - *next = new; > - next = &new->next; > + QAPI_LIST_APPEND(tail, > + g_strdup(x86_cpu_feature_name(w, i))); > } > } > } > @@ -4851,16 +4848,13 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v, > * running using the current machine and accelerator. > */ > static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, > - strList **missing_feats) > + strList **tail) Likewise. > { > X86CPU *xc; > Error *err = NULL; > - strList **next = missing_feats; > > if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { > - strList *new = g_new0(strList, 1); > - new->value = g_strdup("kvm"); > - *missing_feats = new; > + QAPI_LIST_APPEND(tail, g_strdup("kvm")); > return; > } > > @@ -4872,16 +4866,13 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, > * but in case it does, just report the model as not > * runnable at all using the "type" property. > */ > - strList *new = g_new0(strList, 1); > - new->value = g_strdup("type"); > - *next = new; > - next = &new->next; > + QAPI_LIST_APPEND(tail, g_strdup("type")); > error_free(err); > } > > x86_cpu_filter_features(xc, false); > > - x86_cpu_list_feature_names(xc->filtered_features, next); > + x86_cpu_list_feature_names(xc->filtered_features, tail); > > object_unref(OBJECT(xc)); > } [...] Other than that: Reviewed-by: Markus Armbruster From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB06EC433DB for ; Wed, 13 Jan 2021 13:19:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED86223432 for ; Wed, 13 Jan 2021 13:19:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED86223432 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzg3H-0004Wu-JW for qemu-devel@archiver.kernel.org; Wed, 13 Jan 2021 08:19:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzg1G-0003oK-Oe for qemu-devel@nongnu.org; Wed, 13 Jan 2021 08:17:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kzg1C-0007c2-03 for qemu-devel@nongnu.org; Wed, 13 Jan 2021 08:17:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610543814; 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: in-reply-to:in-reply-to:references:references; bh=bK15k+xdC4A0Up4JkR6Lu7Rifjs8QZM7pyf/z0RA6aM=; b=XtGVBB3OrA6WuVPYAebdELjhPbtRI+Sr4TaS1AA2s59ezFTlzitOwv/ZYd8N/yLec0KYKx xQPcKftFbaL1uU4lMzdUUZ4Sgjzjlgz1yj4Nj46OKScn/ixJ6gSUUrIXetGpjWebUT9B3v oP6xKyVdI7ejkkOiGltqwVRaezeMGYI= 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-192-JYKNl7sSP0ifdoqRF6OHdw-1; Wed, 13 Jan 2021 08:16:53 -0500 X-MC-Unique: JYKNl7sSP0ifdoqRF6OHdw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8DB21005D44; Wed, 13 Jan 2021 13:16:51 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51E2360BF1; Wed, 13 Jan 2021 13:16:48 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CB1DA11386A7; Wed, 13 Jan 2021 14:16:46 +0100 (CET) From: Markus Armbruster To: Eric Blake Subject: Re: [PATCH v3 6/7] qapi: Use QAPI_LIST_APPEND in trivial cases References: <20201223221102.390740-1-eblake@redhat.com> <20201223221102.390740-7-eblake@redhat.com> Date: Wed, 13 Jan 2021 14:16:46 +0100 In-Reply-To: <20201223221102.390740-7-eblake@redhat.com> (Eric Blake's message of "Wed, 23 Dec 2020 16:11:01 -0600") Message-ID: <87v9c1yo1t.fsf@dusky.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 , Fam Zheng , Vladimir Sementsov-Ogievskiy , "Daniel P. =?utf-8?Q?Berrang=C3=A9?=" , Eduardo Habkost , "open list:Dirty Bitmaps" , "Michael S. Tsirkin" , "open list:Trivial patches" , Michael Roth , Richard Henderson , qemu-devel@nongnu.org, Max Reitz , Michael Tokarev , Igor Mammedov , Paolo Bonzini , John Snow , "Dr. David Alan Gilbert" , Laurent Vivier Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Eric Blake writes: > 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 > --- [...] > diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c > index 6350caa76530..3f3182007b07 100644 > --- a/hw/acpi/cpu.c > +++ b/hw/acpi/cpu.c > @@ -42,16 +42,12 @@ static ACPIOSTInfo *acpi_cpu_device_status(int idx, AcpiCpuStatus *cdev) > return info; > } > > -void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list) > +void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***tail) > { > int i; Sure you want to rename the parameter? What about: void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list) { + ACPIOSTInfoList ***tail = list; int i; > > for (i = 0; i < cpu_st->dev_count; i++) { > - ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1); > - elem->value = acpi_cpu_device_status(i, &cpu_st->devs[i]); > - elem->next = NULL; > - **list = elem; > - *list = &elem->next; > + QAPI_LIST_APPEND(*tail, acpi_cpu_device_status(i, &cpu_st->devs[i])); > } > } > > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c > index f2552b2a4624..e4b836bd5e46 100644 > --- a/hw/acpi/memory_hotplug.c > +++ b/hw/acpi/memory_hotplug.c > @@ -51,16 +51,13 @@ static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) > return info; > } > > -void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list) > +void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***tail) Likewise. > { > int i; > > for (i = 0; i < mem_st->dev_count; i++) { > - ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1); > - elem->value = acpi_memory_device_status(i, &mem_st->devs[i]); > - elem->next = NULL; > - **list = elem; > - *list = &elem->next; > + QAPI_LIST_APPEND(*tail, > + acpi_memory_device_status(i, &mem_st->devs[i])); > } > } > [...] > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index 35459a38bb1c..95326285b76d 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -4817,20 +4817,17 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose); > > /* Build a list with the name of all features on a feature word array */ > static void x86_cpu_list_feature_names(FeatureWordArray features, > - strList **feat_names) > + strList **tail) Likewise. > { > FeatureWord w; > - strList **next = feat_names; > > for (w = 0; w < FEATURE_WORDS; w++) { > uint64_t filtered = features[w]; > int i; > for (i = 0; i < 64; i++) { > if (filtered & (1ULL << i)) { > - strList *new = g_new0(strList, 1); > - new->value = g_strdup(x86_cpu_feature_name(w, i)); > - *next = new; > - next = &new->next; > + QAPI_LIST_APPEND(tail, > + g_strdup(x86_cpu_feature_name(w, i))); > } > } > } > @@ -4851,16 +4848,13 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v, > * running using the current machine and accelerator. > */ > static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, > - strList **missing_feats) > + strList **tail) Likewise. > { > X86CPU *xc; > Error *err = NULL; > - strList **next = missing_feats; > > if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { > - strList *new = g_new0(strList, 1); > - new->value = g_strdup("kvm"); > - *missing_feats = new; > + QAPI_LIST_APPEND(tail, g_strdup("kvm")); > return; > } > > @@ -4872,16 +4866,13 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, > * but in case it does, just report the model as not > * runnable at all using the "type" property. > */ > - strList *new = g_new0(strList, 1); > - new->value = g_strdup("type"); > - *next = new; > - next = &new->next; > + QAPI_LIST_APPEND(tail, g_strdup("type")); > error_free(err); > } > > x86_cpu_filter_features(xc, false); > > - x86_cpu_list_feature_names(xc->filtered_features, next); > + x86_cpu_list_feature_names(xc->filtered_features, tail); > > object_unref(OBJECT(xc)); > } [...] Other than that: Reviewed-by: Markus Armbruster