From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIEVI-00013v-C2 for qemu-devel@nongnu.org; Fri, 15 Aug 2014 06:13:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIEV6-0001AN-UT for qemu-devel@nongnu.org; Fri, 15 Aug 2014 06:13:00 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:52657) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIEV5-00018r-7x for qemu-devel@nongnu.org; Fri, 15 Aug 2014 06:12:48 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Aug 2014 20:12:43 +1000 From: Alexey Kardashevskiy Date: Fri, 15 Aug 2014 20:12:23 +1000 Message-Id: <1408097555-28126-2-git-send-email-aik@ozlabs.ru> In-Reply-To: <1408097555-28126-1-git-send-email-aik@ozlabs.ru> References: <1408097555-28126-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [RFC PATCH v2 01/13] qom: Make object_child_foreach safe for objects removal List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , Alexander Graf , Gavin Shan , Alex Williamson , qemu-ppc@nongnu.org, David Gibson Current object_child_foreach() uses QTAILQ_FOREACH() to walk through children and that makes children removal from the callback impossible. This makes object_child_foreach() use QTAILQ_FOREACH_SAFE(). Signed-off-by: Alexey Kardashevskiy --- This went to Andreas's qom-next tree, it is here for the reference only. --- qom/object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index 0e8267b..4a814dc 100644 --- a/qom/object.c +++ b/qom/object.c @@ -678,10 +678,10 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), void *opaque) { - ObjectProperty *prop; + ObjectProperty *prop, *next; int ret = 0; - QTAILQ_FOREACH(prop, &obj->properties, node) { + QTAILQ_FOREACH_SAFE(prop, &obj->properties, node, next) { if (object_property_is_child(prop)) { ret = fn(prop->opaque, opaque); if (ret != 0) { -- 2.0.0