From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2l4T-0002Wy-MG for qemu-devel@nongnu.org; Fri, 26 Jul 2013 12:40:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2l4S-0003qp-G4 for qemu-devel@nongnu.org; Fri, 26 Jul 2013 12:40:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2l4S-0003pW-88 for qemu-devel@nongnu.org; Fri, 26 Jul 2013 12:40:48 -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 r6QGeldO023891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Jul 2013 12:40:47 -0400 Message-ID: <51F2A68E.1020300@redhat.com> Date: Fri, 26 Jul 2013 10:40:46 -0600 From: Eric Blake MIME-Version: 1.0 References: <1374584606-5615-1-git-send-email-kwolf@redhat.com> <1374584606-5615-18-git-send-email-kwolf@redhat.com> In-Reply-To: <1374584606-5615-18-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ethdv0v1rqCRpDpdi5qc7qhMVkRhbvvQr" Subject: Re: [Qemu-devel] [PATCH 17/18] Implement qdict_flatten() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ethdv0v1rqCRpDpdi5qc7qhMVkRhbvvQr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 operati= on > is applied recursively for nested QDicts. >=20 > Signed-off-by: Kevin Wolf > --- > include/qapi/qmp/qdict.h | 1 + > qobject/qdict.c | 50 ++++++++++++++++++++++++++++++++++++++++= ++++++++ > 2 files changed, 51 insertions(+) > + while (entry !=3D NULL) { > + > + next =3D qdict_next(qdict, entry); next points to a position in the unmodified qdict... > + value =3D qdict_entry_value(entry); > + new_key =3D NULL; > + delete =3D false; > + > + if (prefix) { > + qobject_incref(value); > + new_key =3D g_strdup_printf("%s.%s", prefix, entry->key); > + qdict_put_obj(target, new_key, value); > + delete =3D true; > + } > + > + if (qobject_type(value) =3D=3D QTYPE_QDICT) { > + qdict_do_flatten(qobject_to_qdict(value), target, > + new_key ? new_key : entry->key); > + delete =3D true; > + } > + > + if (delete) { > + qdict_del(qdict, entry->key); > + > + /* Restart loop after modifying the iterated QDict */ > + entry =3D qdict_first(qdict); =2E..now entry points to the head of the modified qdict, since the modification may have re-arranged where we would iterate next... > + } > + > + entry =3D next; =2E..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)'. If you agree with my analysis and incorporate my suggested fix, then I'm okay if you add: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ethdv0v1rqCRpDpdi5qc7qhMVkRhbvvQr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJR8qaOAAoJEKeha0olJ0NqBBcH/3i5HRucM3kDdSj3kSiVaCZG zIN+n/6bBN74BneY6f93ISB790ImyQJbMme2Kvqge8o5p0P8ba8TGgrdX+e7jjPO ZFHcYAduz+XemYAHuxZF+k6RgqAN5ZwEQ/y9863aNL2haVfDRggxVxlQ01PfqQFb Tm0/3srG32fRlwycyn3yPVgg7tkEQvmgMJVeALyhQybXK2aXvq3jxyP39TRH3vTw D0NQndiJ3tLEXjkL59HvYmLRIH8t0kkgq0QAEtzR4Sn6TMeCOmGSqzADwRLjTvhp jVmN8h2PQVkjoaWeUjSlGtFI1bCQyZME/eg8M5b9l4Q6CRlBe2DfNItMiqxIlw0= =lB5Y -----END PGP SIGNATURE----- --ethdv0v1rqCRpDpdi5qc7qhMVkRhbvvQr--