From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2lQ8-0007ak-8V for qemu-devel@nongnu.org; Fri, 26 Jul 2013 13:03:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2lQ7-0003dL-CY for qemu-devel@nongnu.org; Fri, 26 Jul 2013 13:03:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2lQ7-0003dC-4G for qemu-devel@nongnu.org; Fri, 26 Jul 2013 13:03:11 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6QH3ApV032307 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Jul 2013 13:03:10 -0400 Date: Fri, 26 Jul 2013 19:03:08 +0200 From: Kevin Wolf Message-ID: <20130726170307.GF18446@dhcp-200-207.str.redhat.com> References: <1374584606-5615-1-git-send-email-kwolf@redhat.com> <1374584606-5615-18-git-send-email-kwolf@redhat.com> <51F2A68E.1020300@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51F2A68E.1020300@redhat.com> Subject: Re: [Qemu-devel] [PATCH 17/18] Implement qdict_flatten() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, lcapitulino@redhat.com Am 26.07.2013 um 18:40 hat Eric Blake geschrieben: > On 07/23/2013 07:03 AM, Kevin Wolf wrote: > > qdict_flatten(): For each nested QDict with key x, all fields with key y > > are moved to this QDict and their key is renamed to "x.y". This operation > > is applied recursively for nested QDicts. > > > > Signed-off-by: Kevin Wolf > > --- > > include/qapi/qmp/qdict.h | 1 + > > qobject/qdict.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 51 insertions(+) > > > > + while (entry != NULL) { > > + > > + next = qdict_next(qdict, entry); > > next points to a position in the unmodified qdict... > > > + value = qdict_entry_value(entry); > > + new_key = NULL; > > + delete = false; > > + > > + if (prefix) { > > + qobject_incref(value); > > + new_key = g_strdup_printf("%s.%s", prefix, entry->key); > > + qdict_put_obj(target, new_key, value); > > + delete = true; > > + } > > + > > + if (qobject_type(value) == QTYPE_QDICT) { > > + qdict_do_flatten(qobject_to_qdict(value), target, > > + new_key ? new_key : entry->key); > > + delete = true; > > + } > > + > > + if (delete) { > > + qdict_del(qdict, entry->key); > > + > > + /* Restart loop after modifying the iterated QDict */ > > + entry = qdict_first(qdict); > > ...now entry points to the head of the modified qdict, since the > modification may have re-arranged where we would iterate next... > > > + } > > + > > + entry = next; > > ...oops, we just undid that, and pointed it back to the old qdict > iteration location. I think you're missing a continue statement inside > 'if (delete)'. Gah, this is getting embarrassing. Who stole my continue? :-) You're right of course, thanks for catching that. I'll fix it. Kevin