From 8af734ca318369c4eb76f355ed4cc7d4e6abc2a6 Mon Sep 17 00:00:00 2001 From: Alexey Kardashevskiy Date: Mon, 14 Jul 2014 00:41:08 +1000 Subject: qom: Make object_child_foreach() safe for objects removal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Hu Tao Signed-off-by: Andreas Färber --- qom/object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index 79bd0cc474..a298b32f8b 100644 --- a/qom/object.c +++ b/qom/object.c @@ -668,10 +668,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) { -- cgit v1.2.3