All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"open list:GLUSTER" <integration@gluster.org>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"open list:GLUSTER" <qemu-block@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	qemu-devel@nongnu.org, "Max Reitz" <mreitz@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Michael Roth" <mdroth@linux.vnet.ibm.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH v2 7/7] qapi: More complex uses of QAPI_LIST_APPEND
Date: Fri, 4 Dec 2020 16:54:23 -0600	[thread overview]
Message-ID: <54de873e-53df-8ed8-291b-d0d17a96d057@redhat.com> (raw)
In-Reply-To: <871rgpg27o.fsf@dusky.pond.sub.org>

On 11/19/20 2:50 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
> 
>> 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.

>> +++ b/hw/core/machine-qmp-cmds.c
> [...]
>> @@ -294,41 +281,31 @@ void qmp_set_numa_node(NumaOptions *cmd, Error **errp)
>>  static int query_memdev(Object *obj, void *opaque)

>>          v = qobject_input_visitor_new(host_nodes);
>> -        visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort);
>> +        visit_type_uint16List(v, NULL, &m->host_nodes, &error_abort);
>>          visit_free(v);
>>          qobject_unref(host_nodes);
>>
>> -        m->next = *list;
>> -        *list = m;
>> +        QAPI_LIST_APPEND(list, m);
> 
> The old code prepends, doesn't it?

Good catch, will correct and hoist this into 4/7 for v3.

> 
>>      }
>>
>>      return 0;
>> diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
>> index cf0627fd01c1..1afcc29a0649 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, **prev = &list;
> 
> Here, you reuse the old name for the new variable.

>> +++ b/hw/pci/pci.c
>> @@ -1681,41 +1681,34 @@ static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num);
>>
>>  static PciMemoryRegionList *qmp_query_pci_regions(const PCIDevice *dev)
>>  {
>> -    PciMemoryRegionList *head = NULL, *cur_item = NULL;
>> +    PciMemoryRegionList *head = NULL, **tail = &head;
> 
> Here, you use a new and better name.
> 
> I'd like to encourage you to name tail pointer variables @tail
> elsewhere, too.

In v3, I will consistently rename the FOOList ** variable 'tail'.

>> @@ -2863,7 +2846,6 @@ qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
>>
>>      while (mem_blks != NULL) {
>>          GuestMemoryBlockResponse *result;
>> -        GuestMemoryBlockResponseList *entry;
>>          GuestMemoryBlock *current_mem_blk = mem_blks->value;
>>
>>          result = g_malloc0(sizeof(*result));
>> @@ -2872,11 +2854,7 @@ qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
>>          if (local_err) { /* should never happen */
>>              goto err;
>>          }
>> -        entry = g_malloc0(sizeof *entry);
>> -        entry->value = result;
>> -
>> -        *link = entry;
>> -        link = &entry->next;
>> +        QAPI_LIST_APPEND(link, result);
>>          mem_blks = mem_blks->next;
>>      }
>>
> 
> This one looks like a candidate for PATCH 6.

Yes.  Will hoist.

v3 will be posted soon.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2020-12-04 22:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13  1:13 [PATCH v2 0/7] Common macros for QAPI list growth Eric Blake
2020-11-13  1:13 ` [PATCH v2 1/7 for-5.2?] net: Fix memory leak on error Eric Blake
2020-11-16 14:22   ` Markus Armbruster
2020-11-16 14:41     ` Eric Blake
2020-11-13  1:13 ` [PATCH v2 2/7] rocker: Revamp fp_port_get_info Eric Blake
2020-11-17  9:27   ` Markus Armbruster
2020-11-13  1:13 ` [PATCH v2 3/7] migration: Refactor migrate_cap_add Eric Blake
2020-11-17  9:45   ` Markus Armbruster
2020-11-13  1:13 ` [PATCH v2 4/7] qapi: Use QAPI_LIST_PREPEND() where possible Eric Blake
2020-11-17 10:20   ` Markus Armbruster
2020-11-17 11:45   ` Stefan Hajnoczi
2020-11-13  1:13 ` [PATCH v2 5/7] qapi: Introduce QAPI_LIST_APPEND Eric Blake
2020-11-17 12:51   ` Markus Armbruster
2020-11-18  0:41     ` Eric Blake
2020-11-18  6:21       ` Markus Armbruster
2020-11-13  1:13 ` [PATCH v2 6/7] qapi: Use QAPI_LIST_APPEND in trivial cases Eric Blake
2020-11-13  1:13 ` [PATCH v2 7/7] qapi: More complex uses of QAPI_LIST_APPEND Eric Blake
2020-11-13 19:39   ` Dr. David Alan Gilbert
2020-11-16 13:27     ` Eric Blake
2020-11-19  8:50   ` Markus Armbruster
2020-12-04 22:54     ` Eric Blake [this message]
2020-11-19  9:28 ` [PATCH v2 0/7] Common macros for QAPI list growth Markus Armbruster
2020-12-19  9:43   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54de873e-53df-8ed8-291b-d0d17a96d057@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=integration@gluster.org \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.